The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> Visual Basic Programming
|
syntax error in from clause vb6
Discuss syntax error in from clause vb6 in the Visual Basic Programming forum on Dev Shed. syntax error in from clause vb6 Visual Basic Programming forum discussing VB specific programming information. Quickly prototype and build applications with this robust and simple language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

April 24th, 2003, 01:38 PM
|
|
Junior Member
|
|
Join Date: Apr 2003
Location: Chico, CA
Posts: 14
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
syntax error in from clause vb6
Hello all,
I'm attempting to open a recordset from an access 2000 .mdb file using vb6 service pack 5, ActiveX ADO 2.7, and I'm gettting a "syntax error in from clause" on the simplest query.
Here's the code:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Private conn As New ADODB.Connection
Private cmd As New ADODB.Command
Private rs As New ADODB.Recordset
Private iTries As Integer
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long
Public OK As Boolean
Private Sub Form_Load()
Dim sBuffer As String
Dim lSize As Long
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\grega\csci 273\phase2\3NF.mdb"
Set cmd.ActiveConnection = conn
cmd.CommandText = "select * from User"
rs.CursorLocation = adUseClient
rs.Open cmd, , adOpenStatic, adLockBatchOptimistic
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
here's what's check in Project->References:
Visual Basic for Applications
Visual Basic runtime objects and procedures
Visual Basic objects and procedures
Microsoft ActiveX Data Objects 2.7 Library
OLE Automation
in that priority order.
nothing but default controls are checked in Project->Components
I can run the same query "select * from User" in Visdata and get no error.
Thanks for the help
Greg
|

April 24th, 2003, 01:44 PM
|
|
Contributing User
|
|
Join Date: Jan 2003
Location: No es importante
Posts: 2,065

Time spent in forums: 6 h 50 m 52 sec
Reputation Power: 13
|
|
|
Spit the query out to the screen just to verify what is being submitted.
|

April 24th, 2003, 02:02 PM
|
|
Junior Member
|
|
Join Date: Apr 2003
Location: Chico, CA
Posts: 14
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
I tried both a debug.print cmd.CommandText and a MsgBox cmd.CommandText, , "Query"
and both look fine, just as it's typed in the code.
|

April 24th, 2003, 02:25 PM
|
|
Overly white
|
|
Join Date: Mar 2003
Location: Fresno, CA
Posts: 83
Time spent in forums: < 1 sec
Reputation Power: 11
|
|
Code:
cmd.CommandText = "select * from User ; "
I think you need to use a semicolon at the end of your SQL. I'm not sure on that though it may be an optional thing.
|

April 24th, 2003, 02:38 PM
|
|
Junior Member
|
|
Join Date: Apr 2003
Location: Chico, CA
Posts: 14
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
nope. Adding a semicolon to the end of the query didn't fix it. I had actually already tried it, but decided to give that another shot.
|

April 24th, 2003, 02:49 PM
|
|
Overly white
|
|
Join Date: Mar 2003
Location: Fresno, CA
Posts: 83
Time spent in forums: < 1 sec
Reputation Power: 11
|
|
how about a semi colon after the connection string.
Code:
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\grega\csci 273\phase2\3NF.mdb;"
It's just got to be a semi colon
Can you run any other query? Maybe try a different table.
|

April 24th, 2003, 03:00 PM
|
|
Junior Member
|
|
Join Date: Apr 2003
Location: Chico, CA
Posts: 14
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
adding a semicolon to the end of the connection string gives me no change.
However, if I switch to a System DSN in ODBC data sources (control panel), and use the following connection string:
conn.Open "DSN=stormnet;uid=sa;pwd=;database=stormnet"
then the query works fine. I would much rather not use the System DSN, does anybody have any ideas?
Greg
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|