VB与sql设计代码:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'选择普通用户登录
If Me.RadioButton1.Checked Then
Dim str As String
str = "data source=PC-201103171305\SQLEXPRESS;database=学生信息库;user id=sa;pwd="
Dim con As New SqlClient.SqlConnection(str)
Try
con.Open()
Catch ex As Exception
End Try
Dim sql As String = "select * from 普通用户where 用户名='" & TextBox1.Text.ToString().Trim() & "' and 密码='" & TextBox2.Text.ToString().Trim() & " '"
Dim cmd As New SqlClient.SqlCommand(sql, con)
Dim reader As SqlClient.SqlDataReader
Try
reader = cmd.ExecuteReader
If reader.Read() = True Then
Dim 学生成绩管理系统As New 学生信息管理系统
学生成绩管理系统.添加DToolStripMenuItem.Enabled = False
学生成绩管理系统.修改KToolStripMenuItem.Enabled = False
学生成绩管理系统.删除DToolStripMenuItem.Enabled = False
学生成绩管理系统.添加ToolStripMenuItem.Enabled = False
学生成绩管理系统.高级用户信息管理ToolStripMenuItem.Enabled = False
学生成绩管理系统.Show()
Me.Hide()
Else
MsgBox("对不起,用户名或密码错误!重新输入(请正确选择用户类型)", 16, "警告")
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
TextBox1.Focus()
End If
Catch ex As Exception
End Try
End If
'选择高级用户登录
If Me.RadioButton2.Checked Then
Dim str As String
str = "data source=PC-201103171305\SQLEXPRESS;database=学生信息库;user id=sa;pwd="
Dim con As New SqlClient.SqlConnection(str)
Try
con.Open()
Catch ex As Exception
End Try
Dim sql As String = "select * from 高级用户where 用户名='" & TextBox1.Text.ToString().Trim() & "
2021-09-30 05:39:19
264KB
VB
1