Private Sub OK_Click(sender As Object, e As EventArgs) Handles OK.ClickIf TextBox1.Text = "" ThenMsgBox("用户名不能为空!!", , "提示")ElseIf TextBox2.Text = "" ThenMsgBox("密码不能为空!!", , "提示")ElseDim sql As String = "select * from 人员表 where 用户名='" & TextBox1.Text.ToString.Trim & "' and 密码='" & TextBox2.Text.ToString.Trim & "'"Dim mycmd As New SqlCommand(sql, conn)Dim myreader As SqlDataReadermyreader = mycmd.ExecuteReaderIf myreader.HasRows Thenmyreader.Read()MsgBox("登录成功!!", , "标题")yonghuming = myreader("用户名").ToString.Trimxingming = myreader("姓名").ToString.Trimbumen = myreader("部门").ToString.TrimFormMain.ToolStripStatusLabel3.Text = myreader("用户名").ToString.Trim & "(" & myreader("姓名").ToString.Trim & ")"Me.Close()FormMain.MenuStrip1.Visible = TrueFormMain.ToolStrip1.Visible = TrueIf myreader("激活状态").ToString.Trim = "0" ThenMsgBox("检测到该用户首次登录,必需将初始密码修改!!", , "标题")FormPassword.MdiParent = FormMainFormPassword.Show()FormPassword.TextBox1.Text = yonghuming & "(" & xingming & ")"ElseIf myreader("激活状态").ToString.Trim = "1" ThenMe.Close()FormMain.MenuStrip1.Visible = TrueFormMain.ToolStrip1.Visible = TrueEnd IfElseMsgBox("输入用户名或密码错误,请重新输入!!", , "标题")TextBox1.Text = ""TextBox2.Text = ""TextBox1.Focus()End Ifmyreader.Close()End IfEnd Sub
1200字范文,内容丰富有趣,写作的好帮手!