me again with another question D:

coward

Member
Joined
Mar 23, 2003
Messages
13
Location
New Zealand
Right, well I gave up on the whole mysql side of things, just so that I could teach myself some more vb using databases (now rather than later - gonna install mysql manually at some stage tho). So I made a test database with access.

so...

command = "SELECT * FROM user WHERE user_id=1"

myconnb.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\test.mdb;"

Try
myconnb.Open()
Catch ex As Exception
MsgBox("Could Not Connect To Database", MsgBoxStyle.Exclamation, "No Connection")
End
End Try

MsgBox("Connecion To Database Test Opened", MsgBoxStyle.Information, "New Connection")

recset = myconnb.Execute(command)

thats my code, but i keep getting "syntax error in FROM statement, and brushing up on my sql is something that I did just to make sure that i was right, and I see no probs at all, so if anyone has an idea let me know :)

cheers
 
Maybe this sample will help;

Code:
Dim con As OleDbConnection
Dim cmd As OleDbCommand
Dim dtr As OleDbDataReader

con = New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=c:\test.mdb")
con.Open()
cmd = New OleDbCommand("SELECT * FROM table", con)
dtr = cmd.ExecuteReader()
con.Close()
 
Originally posted by wyrd
Maybe this sample will help;

Code:
Dim con As OleDbConnection
Dim cmd As OleDbCommand
Dim dtr As OleDbDataReader

con = New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=c:\test.mdb")
con.Open()
cmd = New OleDbCommand("SELECT * FROM table", con)
dtr = cmd.ExecuteReader()
con.Close()

mm i was using adodb as my base, and did think about using oledb, but was unsure of the commands - ill give it a go :)
 
mmm have i not included something properly because i have to enter your instances of

OleDbConnection
OleDbCommand
OleDbDataReader


as

OleDb.OleDbConnection
OleDb.OleDbCommand
OleDb.OleDbDataReader
 
To my understanding, your error message quite clearly indicated that there *is* a problem in your SQL. Maybe "user" is a reserved word ?

Anyway, try to submit excactly your SQL Statement in the databases command interface and see what happens.

In your case: Create a Query and switch to the SQL View.

Maybe you need to put brackets around the table name as in
SELECT * FROM [user] WHERE ...
 
well slap me with a stick, and call me fugly !

the whole square bracket thing worked no probs...ffs i tried that too but in my other connection which was also not working D:

oh well

cheers heiko!!
 
Back
Top