【正文】
Dim sqlconnstr As String = (ConnectionString).ConnectionString Dim sqlconn As SqlConnection = New SqlConnection(sqlconnstr) () Dim sqlmand As SqlCommand = New SqlCommand(select * from admin where 用戶名=39。 + () + 39。and 密碼=39。 + () + 39。and 用戶類型=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é)生成績主要代碼: 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 成績表 where 學(xué)號=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 用戶名=39。 + () + 39。and 用戶類型= 39。 + () + 39。 (@密碼, ) Try () intupdatecount = If (intupdatecount 0) Then = 修改成功! Else = 修改失??! End If Catch ex As Exception = 錯誤原因: + 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)教師對學(xué)生成績的添加主要代碼: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對象 Dim sqlmand As SqlCommand = New SqlCommand() = sqlconn 39。把SQL語句賦給Command對象 = insert into 成績表(學(xué)號,姓名,課程名,考核方式,學(xué)期,成績) values (@學(xué)號,@姓名,@課程名,@考核方式,@學(xué)期,@成績) (@學(xué)號, ) (@姓名, ) (@課程名, ) (@考核方式, ) (@學(xué)期, ) (@成績, ) Try 39。打開連接 () 39。執(zhí)行SQL命令 () = 恭喜您!添加成功! = = = = 考試 = 1 Catch ex As Exception = 對不起!添加失??! = = = = 考試 = 1 Finally sqlmand = Nothing () sqlconn = Nothing End Try End Sub