borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (ADO & MS Access)Next Topic (VB6 => Access2000, Passing 2 Parameters?) New Topic New Poll Post Reply
AndreaVB Forum : Database : select statements
Poster Message
sunflower
Level: Guest


icon select statements  Archived to Disk

Hi,

Is there a specific connection that needs to be used when trying to open a recordset with an sql statement?  Here's the code I'm using to create the connection:

Set adoConnect = New ADODB.Connection
strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=filestructure04.mdb"
adoConnect.Open strCnn
    
Set adoRecordset = New ADODB.Recordset
adoRecordset.CursorType = adOpenKeyset
adoRecordset.LockType = adLockOptimistic
adoRecordset.Open "SELECT * FROM struct04", adoConnect, , , adCmdTable

The error I get when running this code is:
"Syntax error in FROM clause", which points to the bolded line in the code shown above.  Can someone please advise on anything I need to include to make this work?

Thanks  

06-08-2002 at 03:42 PM
| Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: select statements  Archived to Disk

The connection that you used to open the database (like you have done)

Make sure "struct04" is a table.

Try:
' Removing the two lines prior to the open line
adoRecordset.Open "SELECT * FROM struct04", adoConnect, adOpenKeyset, adLockOptimistic
-OR-
' If you keep the prior two lines
adoRecordset.Open "SELECT * FROM struct04", adoConnect

06-08-2002 at 08:24 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
ASHISH25
Level: Guest

icon Re: select statements  Archived to Disk

quote:
sunflower wrote:
Hi,

Set adoConnect = New ADODB.Connection
strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=filestructure04.mdb"
adoConnect.Open strCnn
    
Set adoRecordset = New ADODB.Recordset
adoRecordset.CursorType = adOpenKeyset
adoRecordset.LockType = adLockOptimistic

use this statement

adoRecordset.Open "SELECT * FROM struct04", adoConnect, , , 1

09-08-2002 at 09:55 AM
| Quote Reply
AndreaVB Forum : Database : select statements
Previous Topic (ADO & MS Access)Next Topic (VB6 => Access2000, Passing 2 Parameters?) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder