标题: VB.Net自学之路之窗体登录主要代码分享 [打印本页] 作者: 18810086920 时间: 2022-8-1 13:49 标题: VB.Net自学之路之窗体登录主要代码分享 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