set conn=New ADODB.Connection
set rs=New adodb.recordset
本机名称:jszx3-11
server:jszx3-11
database:wzc
uid=sa
pwd=
driver={sql server}
''定义ADO数据库对象
conn.ConnectionString = "driver={SQL Server};" & _
"server=" & ServerName & ";uid=" & UserName & ";
pwd=" & Password & ";database=" & DatabaseName & ""
''连接数据串
Private Sub Command1_Click(Index As Integer)
Dim m As String
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.ConnectionString = "Driver={SQL Server};server=JSZX3-11;uid=sa;pwd=;database=wzc"
conn.Open
rs.Open "select 用户名,密码 from login where 用户名=''" & Trim(Combo1.Text) & "'' And 密码=''" & Trim(Text1.Text) & "''", conn, adOpenStatic, adLockReadOnly, adCmdText
If rs.EOF = True And rs.BOF Then
m = MsgBox("请重新登录",
vbExclamation)
Text1.Text = ""
Text1.SetFocus
Else
Form1.Hide
Form2.Show
End If
rs.Close
End Sub
Private Sub Command2_Click(Index As Integer)
Form2.Show
End Sub
Private Sub Command3_Click()
Unload Form1
End Sub
Private Sub Form_Load()
Dim t As Integer
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.ConnectionString = "Driver={SQL Server};server=JSZX3-11;uid=sa;pwd=;database=wzc"
conn.Open
rs.Open "select 用户名 from login", conn, adOpenStatic, adLockReadOnly, adCmdText
Dim i As String
For t = 0 To Val(rs.RecordCount) - 1
i = Trim(rs.Fields("用户名").Value)
rs.MoveNext
Combo1.AddItem i
Next t
rs.Close
End Sub