
ODBC's driving me nuts!!!
Quote:
> I'm working on a VB4 app to query my database (currently Gupta, but I'll
> switch to SQL Server for production.) I'm looking to connect with code
> instead of using the data control for speed's sake. If I specify the
> table alone, I don't seem to have any problems. However, I don't want to
> have to read the entire table into my recordset. My problem is that any
> time I try to use a query statement, I get an error message that the
> table can't be found. I've provided my code for review. Any assistance
> would be greatly appreciated!
> Sub dbConnect()
> Connect$ = "ODBC;DSN=xxx;DATABASE=xxx;UID=xxx;PWD=xxx;"
> Set db = OpenDatabase("", True, True, Connect$)
> Dim sQuery As String
> sQuery$ = "SELECT FOLDERID FROM DOCUMENT;"
> 'this is the line that causes the problem
> Set rs = db.OpenRecordset(sQuery$, dbOpenSnapshot, dbReadOnly)
> 'this statement works fine, I just have to call the whole table
> 'Set rs = db.OpenRecordset("SYSADM.DOCUMENT", dbOpenSnapshot,
> dbReadOnly)
> 'I just used this as example as to how I would currently display the
> 'data. The text boxes take the data ok.
> Text1.Text = rs(0)
> Text2.Text = rs(1)
> End Sub
Sometimes the ODBC driver will not like the ";" at the end. Outside of
that you might try enabling the ODBC trace facility and see exactly what
VB/JET is sending. Of course, that is assuming that the table DOCUMENT
does really exist in the database you are attaching to...
D.M. (Mike) Mattix
Monsanto Company
Luling Plant
Luling, LA