Error 3131 Syntax error in FROM clause - using SQL accessing external ODBC problem 
Author Message
 Error 3131 Syntax error in FROM clause - using SQL accessing external ODBC problem

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...

Private Sub Form_Activate()
    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

End Sub

And this is the Data control settings...

   Begin VB.Data Data2
      Connect         =   ""
      DatabaseName    =   ""
      Exclusive       =   0   'False
      Options         =   0
      ReadOnly        =   0   'False
      RecordsetType   =   1  'Dynaset
      RecordSource    =   "dbo.Logins"
   End

Thanks Marv



Mon, 08 Jun 1998 03:00:00 GMT  
 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



Mon, 08 Jun 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Error 3131 Syntax error in FROM clause - using SQL accessing external ODBC problem

2. # error 3131 # vb 6.0 pro importing errors

3. # error 3131 # vb 6.0 pro importing errors

4. SQL Syntax error in ORDER BY clause.(-2147217900)

5. SQL Syntax error in FROM Clause...but WHY?

6. FROM clause syntax error with sensible SQL query to Excel database

7. Error-2147217900, Syntax error in FROM clause

8. run-time error '3131'

9. Syntax error in FROM clause

10. Help - syntax error in from clause

11. Syntax error in FROM clause??

12. VB Syntax error in FROM Clause

 

 
Powered by phpBB® Forum Software