【正文】
Dim sqlconnstr As String = (ConnectionString).ConnectionString Dim sqlconn As SqlConnection = New SqlConnection(sqlconnstr) () Dim sqlmand As SqlCommand = New SqlCommand(select * from admin where 用戶(hù)名=39。 + () + 39。and 密碼=39。 + () + 39。and 用戶(hù)類(lèi)型=39。 + + 39。, sqlconn) Dim count As String = () Session(usestatues) = Session(username) = If count Nothing And Session(usestatues) = 管理員 Then () ElseIf count Nothing And Session(usestatues) = 教師 Then () ElseIf count Nothing And Session(usestatues) = 學(xué)生 Then () Else = End If End Sub(2)查看學(xué)生成績(jī)主要代碼: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As ) Handles Dim sqlconnstr As String = (ConnectionString).ConnectionString Dim sqlconn As SqlConnection = New SqlConnection(sqlconnstr) Dim ds As DataSet = New DataSet() () Dim sqld As SqlDataAdapter = New SqlDataAdapter(select * from 成績(jī)表 where 學(xué)號(hào)=39。 + () + 39。, sqlconn) (ds, tabgrade) = (tabgrade).DefaultView () () sqlconn = NothingEnd Sub(3)修改密碼主要代碼:Protected Sub Button1_Click(ByVal sender As Object, ByVal e As ) Handles Dim intupdatecount As Integer Dim sqlconnstr As String = (ConnectionString).ConnectionString Dim sqlconn As SqlConnection = New SqlConnection(sqlconnstr) Dim sqlmand As SqlCommand = New SqlCommand() = sqlconn = update admin set 密碼=@密碼 where 用戶(hù)名=39。 + () + 39。and 用戶(hù)類(lèi)型= 39。 + () + 39。 (@密碼, ) Try () intupdatecount = If (intupdatecount 0) Then = 修改成功! Else = 修改失??! End If Catch ex As Exception = 錯(cuò)誤原因: + Finally sqlmand = Nothing () sqlconn = Nothing End Try End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As ) Handles Dim username As String Dim yonghul As String username = Session(username) yonghul = Session(usestatues) = yonghul = username End Sub(4)教師對(duì)學(xué)生成績(jī)的添加主要代碼:Protected Sub Button2_Click(ByVal sender As Object, ByVal e As ) Handles Dim sqlconnstr As String = (ConnectionString).ConnectionString Dim sqlconn As SqlConnection = New SqlConnection(sqlconnstr) 39。建立Command對(duì)象 Dim sqlmand As SqlCommand = New SqlCommand() = sqlconn 39。把SQL語(yǔ)句賦給Command對(duì)象 = insert into 成績(jī)表(學(xué)號(hào),姓名,課程名,考核方式,學(xué)期,成績(jī)) values (@學(xué)號(hào),@姓名,@課程名,@考核方式,@學(xué)期,@成績(jī)) (@學(xué)號(hào), ) (@姓名, ) (@課程名, ) (@考核方式, ) (@學(xué)期, ) (@成績(jī), ) Try 39。打開(kāi)連接 () 39。執(zhí)行SQL命令 () = 恭喜您!添加成功! = = = = 考試 = 1 Catch ex As Exception = 對(duì)不起!添加失??! = = = = 考試 = 1 Finally sqlmand = Nothing () sqlconn = Nothing End Try End Sub