+ Reply to Thread
Results 1 to 3 of 3

DownLoading Data from SQL Server

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    DownLoading Data from SQL Server

    I am using the following code to download data from SQL server.
    Please Login or Register  to view this content.
    When I run this The line rst.Open StrSql, ConnStr is highlighted and the SQL server error message "Invalid column name StartDate" is shown.
    StartDate and LastDate are parameter variables used in the last part of StrSQL. I have replaced these with several other names but all give the same error.
    This is the first time I have queried an SQL server and the first time I have used an ADODB connection so I am stuck.
    Help please

    ***NB The last line of StrSQL has a> and a< replaced by "2" and "3". This is because > and < are causing a Forum FireWall to activate. (See recent post from me and advice given)
    John

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

    Re: DownLoading Data from SQL Server

    You need to put the variables into the string, right now you're just passing a string with "StartDate" and "EndDate" in.

    Please Login or Register  to view this content.

    P.S Always format your dates so that they're unambiguous when using databases

  3. #3
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: DownLoading Data from SQL Server

    Thank you for your help. Your code worked fine. All I had to do was make sure the formatting was done outside the SQL string.
    John

+ 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. Replies: 9
    Last Post: 12-23-2016, 10:54 PM
  2. [SOLVED] Macro for downloading data from web
    By harishb63 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-12-2013, 10:18 AM
  3. VBA - Downloading .csv files from FTP server to worksheet(s)
    By bwhyte21 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-10-2013, 11:32 AM
  4. Populate Server Function based on Server Name for Server Inventory
    By mvcp007 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-13-2013, 11:29 AM
  5. Downloading Data From Yahoo
    By asavage in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-08-2009, 04:39 PM
  6. Downloading data into Excel
    By Akif in forum Excel General
    Replies: 5
    Last Post: 04-23-2007, 10:51 PM
  7. downloading data
    By bloc6 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-02-2006, 11:49 AM

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