Office中国论坛/Access中国论坛

标题: 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




作者: tmtony    时间: 2022-8-4 12:49
不错
作者: roych    时间: 2022-8-13 16:00
可以先看看todaynew的一些帖子,少走一些弯路。@tmtony 话说,老汉好像很久没来论坛了,在鼓捣啥了呢?




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3