SPONSORS:






User Tag List

Results 1 to 5 of 5
  1. #1
    Senior Member
    Join Date
    Mar 2001
    Posts
    161
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    DB__Connect to EXCEL spreadsheet

    User walter earley (wearley26@yahoo.com) posted:

    I want extremely simple connection to EXCEL
    spreadsheet:
    fname lname number
    fname lname number

    Windows 98
    start/settings/control/ODBC
    datasourcename : datasource1
    workbook: filename.xls


    Silktest
    // This test uses the functions in DBTester
    // to directly access an ODBC database
    INTEGER iD3
    STRING sDeptName, sName1, sName2
    HDATABASE hdbc
    HSQL hstmnt
    // connect to EXCEL Spreadsheet
    hdbc = DB_Connect ("dsn=datasource1")
    // retrieve info from Department table
    hstmnt = DB_ExecuteSql (hdbc, "SELECT *")
    // process the information that came back
    print ("Here's the info in the Department table:")
    ] print ()
    while (DB_FetchNext (hstmnt, sName1,sName2,iD3))
    print ("Name: {sName1} {sName2} Number:
    {iD3}")
    // release resources (unneeded really
    // because immediately followed by disconnect)
    DB_FinishSQL (hstmnt)
    // disconnect
    DB_Disconnect (hdbc)

    i am getting errors in the SQL statement. any ideas?


    __________________________________________________

  2. #2
    bjc
    bjc is offline
    Member
    Join Date
    Jan 2000
    Location
    CT
    Posts
    66
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: DB__Connect to EXCEL spreadsheet

    hstmnt = DB_ExecuteSql (hdbc, "SELECT *")

    You need to specify the worksheet name in your SELECT statement.

    hstmnt = DB_ExecuteSql (hdbc, "SELECT * FROM `Sheet1$`")

    ------------------

  3. #3
    Guest

    Re: DB__Connect to EXCEL spreadsheet

    Here is some code to do what you want. Search on Excel and you will find many threads related to how to do this.


    ------------------


    [This message has been edited by John Burross (edited 04-09-2001).]

  4. #4
    Junior Member
    Join Date
    Apr 2001
    Location
    marlboro, ma, usa
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: DB__Connect to EXCEL spreadsheet

    correction to above:
    string sSQL = "SELECT * FROM `Sheet1$`"

    thank you all for help...


  5. #5
    Guest

    Re: DB__Connect to EXCEL spreadsheet

    Actually, the correct syntax is to repeat the `Sheet1$` twice. Quite honestly, I forget why, but that's the way it was explained in the Segue@work article. If it works without the second `Sheet1$` go for it, but if you run into problems, I would start debuggin there.

    ------------------

 

 

Posting Permissions

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

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 02:28 AM.

Copyright BetaSoft Inc.