Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 24th, 2003, 01:38 PM
gadams00 gadams00 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Chico, CA
Posts: 14 gadams00 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #2  
Old April 24th, 2003, 01:44 PM
victorpendleton victorpendleton is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: No es importante
Posts: 2,065 victorpendleton User rank is Private First Class (20 - 50 Reputation Level)victorpendleton User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 44 m 30 sec
Reputation Power: 8
Spit the query out to the screen just to verify what is being submitted.
__________________
El éxito consiste en una serie de pequeñas victorias día a día

MySQL, MS SQL, MS ACCESS, Oracle Database Manager - http://victorpendleton.net/products/psdviewer.html

Reply With Quote
  #3  
Old April 24th, 2003, 02:02 PM
gadams00 gadams00 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Chico, CA
Posts: 14 gadams00 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #4  
Old April 24th, 2003, 02:25 PM
defjamninja defjamninja is offline
Overly white
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Fresno, CA
Posts: 83 defjamninja User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
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.

Reply With Quote
  #5  
Old April 24th, 2003, 02:38 PM
gadams00 gadams00 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Chico, CA
Posts: 14 gadams00 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #6  
Old April 24th, 2003, 02:49 PM
defjamninja defjamninja is offline
Overly white
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Fresno, CA
Posts: 83 defjamninja User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
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.

Reply With Quote
  #7  
Old April 24th, 2003, 03:00 PM
gadams00 gadams00 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: Chico, CA
Posts: 14 gadams00 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > syntax error in from clause vb6


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT