ODBC's driving me nuts!!! 
Author Message
 ODBC's driving me nuts!!!

1 suggestion. might help.
a. qualify the table name with owner's name. the user might be different
from the owner through the user might have select permissions to the table.
 example. SELECT FOLDERID FROM DBO.DOCUMENT

PS: You don't have to terminate your sql statement with a ";". The ";" is
used as a SQL statement terminator in standard ANSI. You are going thru the
JET engine.

Saranga Kumar



Quote:

> 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)



Sun, 07 Feb 1999 03:00:00 GMT  
 ODBC's driving me nuts!!!

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
--
Cary D. Beuershausen,
Systems Engineer
Advanced Data Systems



Sun, 07 Feb 1999 03:00:00 GMT  
 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



Mon, 08 Feb 1999 03:00:00 GMT  
 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
> --
> Cary D. Beuershausen,
> Systems Engineer
> Advanced Data Systems


Two things to try.

1. I don't think the semi-colon at the end is necessary.  This may be the
problem.

or

2. In your query string, try to further clarify your table as follows:
sQuery$ = "SELECT FOLDERID FROM SYSADM.DOCUMENT"

with or without the semi-colon



Mon, 08 Feb 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. It's Driving Me Nuts!

2. Stupid newbie question that's driving me nuts

3. OFFICE ASSISTANTS WITH VB5 PLS HELP IT'S DRIVING ME NUTS :O

4. Copmarison loop driving me nuts!

5. Property Procs Driving me nuts

6. conversion error that is driving me nuts...

7. Unique GUID for each form at creation time - this one drives me nuts

8. MaskEdit Control and Date are driving me nuts!!!!

9. This one is driving me nuts.

10. DAO Issue -- Invalid Page Fault Driving Me Nuts!

11. This is driving me NUTS!!!!

12. Changing colors on different computer driving me nuts!!!

 

 
Powered by phpBB® Forum Software