应用情况 Private SqlStr As String Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbkeytrturn Then Text1.SetFocus End SubPrivate Sub Command1_Click() If Len(Combo1.Text) = 0 Then MsgBox "用户名不能为空!", , "操作提示!" Combo1.SelStart = 0 Combo1.SelLength = Len(Combo1.Text) Combo1.SetFocus Exit Sub End If
SqlStr = "select * from PassView where (用户名='" + Combo1.Text + "') and (密码='" + Text1.Text + "')" If DataEnv.rslogin.State = adStateOpen Then DataEnv.rslogin.Close End If DataEnv.rslogin.Open SqlStr If DataEnv.rslogin.RecordCount = 0 Then MsgBox "用户名或密码错误" Text1.Text = "" Text1.SetFocus Exit Sub Else Form2.Show End If End Sub
和操作SqlServer一个样,把驱动{Microsoft ODBC for SqlServer}改为{Microsoft ODBC for Oracle}。 Conn.ConnectionString= "driver="{Microsoft ODBC for Oracle};UID=*****;PWD=*****;SERVER=servername;" Conn.Open
Private SqlStr As String
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbkeytrturn Then Text1.SetFocus
End SubPrivate Sub Command1_Click() If Len(Combo1.Text) = 0 Then
MsgBox "用户名不能为空!", , "操作提示!"
Combo1.SelStart = 0
Combo1.SelLength = Len(Combo1.Text)
Combo1.SetFocus
Exit Sub
End If
SqlStr = "select * from PassView where (用户名='" + Combo1.Text + "') and (密码='" + Text1.Text + "')"
If DataEnv.rslogin.State = adStateOpen Then
DataEnv.rslogin.Close
End If
DataEnv.rslogin.Open SqlStr
If DataEnv.rslogin.RecordCount = 0 Then
MsgBox "用户名或密码错误"
Text1.Text = ""
Text1.SetFocus
Exit Sub
Else
Form2.Show
End If
End Sub
http://support.microsoft.com/default.aspx?scid=kb;zh-cn;176086&Product=vbb
Conn.ConnectionString= "driver="{Microsoft ODBC for Oracle};UID=*****;PWD=*****;SERVER=servername;"
Conn.Open