📄 module1.vb
字号:
Imports System.Data.SqlClient
Module Module1
Public cnstr As String
Public Sub ShowMsg(ByVal msg As String)
MessageBox.Show(msg, "success", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Public Function validateLogin(ByVal uid As String, ByVal pwd As String) As Boolean
Dim IsCorrect As Boolean = False
Dim cnmy As New SqlConnection(cnstr)
Dim cmd As New SqlCommand
With cmd
.Connection = cnmy
.CommandType = CommandType.Text
.CommandText = "select count(*) from manager where Man_id=@Man_id and Man_pwd=@Man_pwd"
End With
Dim mMan_id As New SqlParameter("@Man_id", SqlDbType.NVarChar, 50)
Dim mMan_pwd As New SqlParameter("@Man_pwd", SqlDbType.NVarChar, 12)
With cmd.Parameters
.Add(mMan_id)
.Add(mMan_pwd)
End With
mMan_id.Value = uid
mMan_pwd.Value = pwd
Try
cnmy.Open()
If cmd.ExecuteScalar = 1 Then
IsCorrect = True
End If
Catch ex As Exception
MessageBox.Show("登陆验证时数据库发生错误" + vbCrLf + ex.Message, _
"error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
Return False
Finally
cnmy.Close()
If Not cnmy Is Nothing Then
cnmy.Dispose()
End If
End Try
Return IsCorrect
End Function
End Module
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -