[img=http://user.qzone.qq.com/963548839/infocenter?ptlang=2052&ADUIN=963548839&ADSESSION=1259046193&ADTAG=CLIENT.QQ.2587_Mysrv.0]大哥大姐我是新手希望数据库能连上单选按钮当单选按钮和数据库里的属性一致时可以打开下个画面帮帮忙。[/img]
Option Explicit
Private Sub Option1_Click()
Option1.Value = True
End Sub
Private Sub Option2_Click()
Option2.Value = True
End Sub
Private Sub Option3_Click()
Option3.Value = True
End Sub
Private Sub Command1_Click()
Form2.Show
Me.Hide
End Sub
Private Sub Command2_Click()
Dim 用户名 As String
Dim 密码 As String
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim StrSQL As String
Dim bo As Boolean
bo = False
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\桌面\教务\db1.mdb"
用户名 = Trim(Text1.Text)
密码 = Trim(Text2.Text)
StrSQL = "select * from 用户 where 用户名= '" & 用户名 & "'and 密码 ='" & 密码 & "'"
rs.Open StrSQL, conn, adOpenKeyset, adLockPessimistic
If 用户名 = "" Or 密码 = "" Then
MsgBox "对不起,用户或密码不能为空!请重新输入!"
Else
If rs.EOF = True Then
MsgBox "对不起,无此用户或者密码不正确!请重新输入!"
Else
bo = True
End If
End If
If bo = True Then
If Option1.Value = True Then
Form3.Show
Form1.Hide
ElseIf Option2.Value = True Then
Form5.Show
Form1.Hide
Else: Option3.Value = True
Form4.Show
Form1.Hide
End If
End If
End Sub
Private Sub Command3_Click()
Unload Me
End Sub