我用VB和sql2000做了个登陆界面,运行是提示[microsoft][odbc驱动程序管理器]中未发现数据源名称并且没有指定默认驱动程序,我已经在管理工具的ODBC指定了数据库,可是还是不行。请高手指导一下,多谢啦!
代码如下。
Dim TIM As Integer
Dim myVal As String
Private Sub Command2_Click()
Dim myVal As String
Beep
myVal = MsgBox("确认退出系统吗?", vbYesNo + vbQuestion, "退出")
If myVal = vbYes Then
Unload Me
Else
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End If
End SubPrivate Sub Command1_Click()
If Text1.Text <> "" And Text2.Text <> "" Then
Adodc1.RecordSource = "select * from dlqx where name='" + Trim(Text1.Text) + "'"
Adodc1.Refresh
If TIM < 2 Then
On Error GoTo errname
If Trim(Text2.Text) = Trim(Adodc1.Recordset.Fields("text2")) Then
Valname = Trim(Adodc1.Recordset.Fields("style"))
Valming = Trim(Text1.Text)
Load Form2
Form2.Show
Unload Me
Exit Sub
Else
MsgBox "您的用户名或密码有误,请重行输入!", vbExclamation + vbDefaultButton1, "错误"
TIM = TIM + 1
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
Exit Sub
End If
Else
myVal = MsgBox("您不是合法用户,请与系统管理员联系!", vbInformation + vbOKOnly, "抱歉")
If myVal = vbOK Then End
Unload Me
End If
Else
MsgBox "请把用户名和密码输全!", vbInformation + vbOKOnly, "提示"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
Exit Sub
End If
errname:
MsgBox "抱歉您的用户名不存在!", vbInformation + vbOKOnly, "抱歉"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
Exit Sub
End SubPrivate Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
Text2.SetFocus
End If
If KeyCode = vbKeyDown Then
Text2.SetFocus
End If
End SubPrivate Sub Text2_(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
Command1.SetFocus
End If
If KeyCode = vbKeyDown Then
Command1.SetFocus
End If
If KeyCode = vbKeyUp Then
Command1.SetFocus
End If
End Sub
Private Sub Command1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyUp Then
Text2.SetFocus
End If
End Sub
代码如下。
Dim TIM As Integer
Dim myVal As String
Private Sub Command2_Click()
Dim myVal As String
Beep
myVal = MsgBox("确认退出系统吗?", vbYesNo + vbQuestion, "退出")
If myVal = vbYes Then
Unload Me
Else
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End If
End SubPrivate Sub Command1_Click()
If Text1.Text <> "" And Text2.Text <> "" Then
Adodc1.RecordSource = "select * from dlqx where name='" + Trim(Text1.Text) + "'"
Adodc1.Refresh
If TIM < 2 Then
On Error GoTo errname
If Trim(Text2.Text) = Trim(Adodc1.Recordset.Fields("text2")) Then
Valname = Trim(Adodc1.Recordset.Fields("style"))
Valming = Trim(Text1.Text)
Load Form2
Form2.Show
Unload Me
Exit Sub
Else
MsgBox "您的用户名或密码有误,请重行输入!", vbExclamation + vbDefaultButton1, "错误"
TIM = TIM + 1
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
Exit Sub
End If
Else
myVal = MsgBox("您不是合法用户,请与系统管理员联系!", vbInformation + vbOKOnly, "抱歉")
If myVal = vbOK Then End
Unload Me
End If
Else
MsgBox "请把用户名和密码输全!", vbInformation + vbOKOnly, "提示"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
Exit Sub
End If
errname:
MsgBox "抱歉您的用户名不存在!", vbInformation + vbOKOnly, "抱歉"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
Exit Sub
End SubPrivate Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
Text2.SetFocus
End If
If KeyCode = vbKeyDown Then
Text2.SetFocus
End If
End SubPrivate Sub Text2_(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
Command1.SetFocus
End If
If KeyCode = vbKeyDown Then
Command1.SetFocus
End If
If KeyCode = vbKeyUp Then
Command1.SetFocus
End If
End Sub
Private Sub Command1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyUp Then
Text2.SetFocus
End If
End Sub
到处点点,右键属性里的“记录源”是不是没选啊