+ Reply to Thread
Results 1 to 13 of 13

ADODB Connection

  1. #1
    Registered User
    Join Date
    03-13-2012
    Location
    Stafford, England
    MS-Off Ver
    Excel 2007
    Posts
    87

    ADODB Connection

    Hi All,


    This is my first time using ADO to connect to our SQL server. I keep getting a syntax error and can't seem to figure out where I am going wrong. Could someone please help me!

    I have attached the syntax that I am using as the form doesn't allow SQL.

    ADODB connection.txt

  2. #2
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: ADODB Connection

    What error are you getting? Is it an excel error, or is the error happening when you attempt to execute the SQL command on the server?


    Also, for a SQL server connection - the connection string should look like this:

    Please Login or Register  to view this content.
    Last edited by GeneralDisarray; 08-06-2015 at 09:42 AM.
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    03-13-2012
    Location
    Stafford, England
    MS-Off Ver
    Excel 2007
    Posts
    87

    Re: ADODB Connection

    Hiya,

    It says syntax error in INSERT INTO statement

  4. #4
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: ADODB Connection

    nevermind- guess I missed something
    Last edited by GeneralDisarray; 08-06-2015 at 10:12 AM.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: ADODB Connection

    There are spaces missing in the SQL statement.
    If posting code please use code tags, see here.

  6. #6
    Registered User
    Join Date
    03-13-2012
    Location
    Stafford, England
    MS-Off Ver
    Excel 2007
    Posts
    87

    Re: ADODB Connection

    Hiya,

    I'm trying to insert values from a spreadsheet and I was using the method shown here http://stackoverflow.com/questions/3...el-into-sql-db

  7. #7
    Registered User
    Join Date
    03-13-2012
    Location
    Stafford, England
    MS-Off Ver
    Excel 2007
    Posts
    87

    Re: ADODB Connection

    Hi Norie,

    Could you please tell me where as I am struggling to find them

  8. #8
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: ADODB Connection

    remove if you please
    Last edited by GeneralDisarray; 08-06-2015 at 10:13 AM.

  9. #9
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: ADODB Connection

    Between the last line and the Where clause

    EDIT in fact at the end of each row

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: ADODB Connection

    There should be spaces before SELECT, FROM and WHERE.

  11. #11
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: ADODB Connection

    I generally avoid this by starting each line with a space:

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    03-13-2012
    Location
    Stafford, England
    MS-Off Ver
    Excel 2007
    Posts
    87

    Re: ADODB Connection

    Thanks for the tip and I've sorted out the spaces but it's still giving me the same error!

  13. #13
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: ADODB Connection

    Wow, I finally got IT to allow me to see that Stack Overflow link - that's a great way to do that

    Nevermind my way
    Last edited by GeneralDisarray; 08-06-2015 at 02:48 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] ADODB Connection Problem?
    By jsabo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2015, 03:23 PM
  2. ADODB connection - Changing connection path via fileDialog
    By cajand in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2015, 08:06 AM
  3. ADODB connection - start on 2nd row?
    By donyc in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-28-2011, 02:31 PM
  4. VBA and ADODB.Connection
    By AedanLee in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-29-2010, 06:37 AM
  5. ADODB Connection String
    By iancallaghan87 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-30-2008, 11:54 AM
  6. vb adodb connection passing value
    By jtwork in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-25-2008, 04:30 PM
  7. [SOLVED] ADODB Connection Problem
    By spardey in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-03-2005, 07:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1