VB连接oracle查询用户是否存在(报错)
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 Sub
Private Sub Command2_Click()
End
End Sub
小弟初学vb,很多东西不是很明白。。看完书还是有点蒙,希望朋友们能帮忙下。。谢谢 --------------------编程问答-------------------- 会发出错误警告:“实时错误3704 对象关闭时不允许操作” --------------------编程问答-------------------- Set Rs = Conn.Execute(SQL)
If Rs!username = checkuid.Text Then
MsgBox ("已经存在!")
Else
MsgBox ("不存在")
End If
==>
If Not rs.Eof Then
MsgBox ("已经存在!")
Else
MsgBox ("不存在")
End If
--------------------编程问答-------------------- Set Rs = Conn.Execute(SQL)
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 --------------------编程问答--------------------
还是会报告错误,指向错误位置为:“Set Rs = Conn.Execute(SQL)” --------------------编程问答-------------------- Set Rs = Conn.Execute(SQL)
==>
Conn.Open Con
Set Rs = Conn.Execute(SQL)
--------------------编程问答--------------------
Private Sub Form_Load()--------------------编程问答-------------------- 连接都没打开,怎么用啊?楼主确实够蒙的
Con = "UID=system;PWD=orcl;DRIVER={Microsoft ODBC for Oracle};" _
& "SERVER=orcl;"
Set Conn = New ADODB.Connection
Conn.Open Con '<-数据库连接要打开才能用
End Sub
补充:VB , 数据库(包含打印,安装,报表)