|
-
Feb 1st, 2002, 10:38 AM
#1
Thread Starter
Junior Member
vb-oracle query
hi,
i was using this code to access data from a table in oracle -
dim cn as new adodb.connection
dim rs as new adodb.recordset
dim str as string
str="select * from products"
cn.connectionstring ="dsn=aaa;uid=aaa;pwd=aaa"
cn.open
rs.open str,cn
now the problem is if that if the table doesnt exist, i get an error which is pretty much obvious. my question is how do i trap this error in VB. or may be how do i code to check whether a table exists in oracle or not. thanks
-
Feb 1st, 2002, 10:40 AM
#2
Hyperactive Member
-
Feb 1st, 2002, 10:50 AM
#3
Thread Starter
Junior Member
re: vb-oracle query
hi glenn,
could you please elaborate a bit on this. thanks.
-
Feb 1st, 2002, 10:57 AM
#4
Hyperactive Member
Reference;
'Microsoft ADO Ext. 2.5 for DDl and Security'
VB Code:
Dim cnnCon As ADODB.Connection
Set cnnCon = New ADODB.Connection
cnnCon.Mode = adModeRead
Dim myCat As New ADOX.Catalog
cnnCon.Open dataText
Set myCat.ActiveConnection = cnnCon
While (i < myCat.Tables.Count)
If ((myCat.Tables(i).Name = "tblMyTable") _
'Do whatever
End If
i = i + 1
Wend
Something like this will enable you to fing if a table exists
-
Feb 1st, 2002, 10:59 AM
#5
To error trap GlenW's code
VB Code:
Private Sub OpenCat()
On Error Goto ErrRtn
Dim cnnCon As ADODB.Connection
Set cnnCon = New ADODB.Connection
cnnCon.Mode = adModeRead
Dim myCat As New ADOX.Catalog
cnnCon.Open dataText
Set myCat.ActiveConnection = cnnCon
While (i < myCat.Tables.Count)
If ((myCat.Tables(i).Name = "tblMyTable") _
'Do whatever
End If
i = i + 1
Wend
Exit Sub
ErrRtn:
Msgbox Err & " " & Error
End Sub
-
Feb 1st, 2002, 11:02 AM
#6
-
Feb 1st, 2002, 12:33 PM
#7
I wouldn't have touched your code had it not been for the fact that kaustav asked, in his original question, how do I error trap (well, maybe I would have anyway...I've just had too many dealings with runtime error that blow my users back to the desktop resulting in angry phone calls say "Hack, your stinkin' program don't work, FIX IT!!")
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|