求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