
Error 3131 Syntax error in FROM clause - using SQL accessing external ODBC problem
Quote:
>I am using VB4Pro on Windows95.
>I am getting the error message 3131: Syntax error in FROM clause.
>I am trying to access an external SQL Server database to query it and
>am having trouble with the following code. Can anyone see what I'm
>doing wrong or is there a better way to do it?
>Here is a snippet of the code...
> Dim Rs As Recordset
> Data2.Connect = "ODBC;DSN=Awinc"
> Data2.Refresh
> Set Rs = Data2.Database.OpenRecordset("SELECT * FROM dbo.Logins IN
>"" [ODBC;DSN=Awinc;] WHERE AccountId = 5688;", dbOpenDynaset)
> Set Data2.Recordset = Rs
I don't believe you need the "IN [ODBC;DSN=Awinc] " part of the
statement. Once you set the .Connect string, that should be the only
place you need to pass the connection information. I've also seen
occasions where it didn't want the trailing semicolon.
Try it like this:
Set Rs = Data2.Database.OpenRecordset("SELECT * FROM dbo.Logins
WHERE AccountId = 5688", dbOpenDynaset)
--
Jim Gilbert Sub Disclaimer()
Monsanto Co. myOpinionsReflectMyEmployers = False
St. Louis, MO End Sub