Option Explicit
Dim Conn As ADODB.Connection
Dim Rs As ADODB.Recordset
Dim uid As String
Dim Con As String
Dim SQL As String
Private Sub Form_Load()
Con = "UID=system;PWD=orcl;DRIVER={Microsoft ODBC for Oracle};" _
& "SERVER=orcl;"
Set Conn = New ADODB.Connection
End Sub
Private Sub Command1_Click()
SQL = "select * from all_users where username='" & checkuid.Text & "'"
Set Rs = Conn.Execute(SQL)
If Rs!username = checkuid.Text Then
MsgBox ("已经存在!")
Else
MsgBox ("不存在")
End If
End SubPrivate Sub Command2_Click()
End
End Sub小弟初学vb,很多东西不是很明白。。看完书还是有点蒙,希望朋友们能帮忙下。。谢谢
Dim Conn As ADODB.Connection
Dim Rs As ADODB.Recordset
Dim uid As String
Dim Con As String
Dim SQL As String
Private Sub Form_Load()
Con = "UID=system;PWD=orcl;DRIVER={Microsoft ODBC for Oracle};" _
& "SERVER=orcl;"
Set Conn = New ADODB.Connection
End Sub
Private Sub Command1_Click()
SQL = "select * from all_users where username='" & checkuid.Text & "'"
Set Rs = Conn.Execute(SQL)
If Rs!username = checkuid.Text Then
MsgBox ("已经存在!")
Else
MsgBox ("不存在")
End If
End SubPrivate Sub Command2_Click()
End
End Sub小弟初学vb,很多东西不是很明白。。看完书还是有点蒙,希望朋友们能帮忙下。。谢谢
If Rs!username = checkuid.Text Then
MsgBox ("已经存在!")
Else
MsgBox ("不存在")
End If==>If Not rs.Eof Then
MsgBox ("已经存在!")
Else
MsgBox ("不存在")
End If
If Rs!username = checkuid.Text Then
MsgBox ("已经存在!")
Else
MsgBox ("不存在")
End If ==> Set Rs = Conn.Execute(SQL)
If Not rs.Eof Then
MsgBox ("已经存在!")
Else
MsgBox ("不存在")
End If
==>
Conn.Open Con
Set Rs = Conn.Execute(SQL)
Con = "UID=system;PWD=orcl;DRIVER={Microsoft ODBC for Oracle};" _
& "SERVER=orcl;"
Set Conn = New ADODB.Connection
Conn.Open Con '<-数据库连接要打开才能用
End Sub