求VB登陆界面详细代码

来源:百度知道 编辑:UC知道 时间:2024/06/27 15:37:23
要求需要 密码,用户名可以登陆,通过所绑定的数据库定义的用户 就是说数据库里的用户名跟密码在登陆界面里都可以登陆! 需要详细的代码 急求哦!!帮忙哦!!!

Public Function OpenConnForSqlServer(ByVal ServerName As String, ByVal UserId As String, ByVal PassWord As String, Optional ByVal DateBaseName As String = "") As ADODB.Connection
Dim AdoConn As New ADODB.Connection
Dim strSql As String
With AdoConn
strSql = "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=" & UserId & ";Password=" & PassWord & ";Data Source=" & ServerName
If DateBaseName <> "" Then strSql = strSql & ";database=" & DateBaseName
.ConnectionString = strSql
.Open
End With
Set OpenConnForSqlServer = AdoConn
End Function

Public Function OpenRecordset(ByVal strSql As String, ByVal AdoConn As ADODB.Connection) As ADODB.Recordset
Dim rs As New ADODB.Recordset
With rs
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.Open strSql