|
vb.net登录主要代码分享Dim SqlConn As SqlConnection, SqlCMD As SqlCommand, SqlDR As SqlDataReader
Dim ConnectionString As String = $"Server={Server};Database={DataBase};UID={UID}WD={PWD}"
Try
Dim SqlStr As String = $"select * from users where UID = '{strUID}' and PWD = '{strPWD}'"
SqlConn = New SqlConnection(ConnectionString)
SqlConn.Open()
SqlCMD = New SqlCommand(SqlStr, SqlConn)
SqlDR = SqlCMD.ExecuteReader
If SqlDR.HasRows Then
SqlDR.Read()
'UID = SqlDR("UID").ToString.Trim
'do something……
Else
MsgBox("用户名或密码错误,请重新输入!")
'do something……
End If
SqlDR.Close()
SqlConn.Close()
Catch ex As Exception
MsgBox(ex.Message)
Finally
releaseObject(SqlCMD)
releaseObject(SqlConn)
End Try
|
|