excel and sql

Discussion in 'Questions (Windows Mobile)' started by gjoisa, Jul 15, 2008.

  1. gjoisa

    gjoisa Active Member Licensed User

    hello all,
    is it possible to copy data from MS Excel file to a sql database ? If yes then how to write code ?:sign0085:
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Open the Excel file and save it as a CSV file.
    Load the CSV file to a Table control with Table.LoadCSV.
    Use Connection.CreateSQLTable to create an SQL table from the Table control.
     
  3. gjoisa

    gjoisa Active Member Licensed User

    Dear Erel,
    I have tried according to your direction . But while running the app, an error message occurs as it can not find the perticular csv file , though the perticular file situated in the same directory . What to do ?
     
  4. agraham

    agraham Expert Licensed User

    Are you referring to it as "Table.LoadCSV(AppPath & "\file.csv")"?
     
  5. gjoisa

    gjoisa Active Member Licensed User

    I have attached my file here . But i could not enclose my csv file here.
     

    Attached Files:

  6. agraham

    agraham Expert Licensed User

    The problem is not reading the csv but that you are confusing the actual database with a table within the database. You need to create or open that database before you create a table in it.
    Code:
    con.New1
    table.LoadCSV(AppPath&
    "\tempad.csv",",",true,true)
    con.Open(
    "Data Source = " & AppPath & "\AdiAtlas.sl3")
    con.CreateSQLTable(
    "table","CSVimport")
    con.Close
     
  7. gjoisa

    gjoisa Active Member Licensed User

    Dear Agraham , I am very thankful to you for your timely response . But the same error persists . The error message reads so " An error occured on sub app_start . Line number: 10 . table.LoadCSV(AppPath & "\tempad.csv",",",true,true) Error description : Could not find file 'F:\A\Basic4PPC\tempad.csv '. Continue ? " . Is there any problem with my 'tempad.csv' ? I just saved an excel file as tempad.csv . However I attached all files here . Can u just check these files once and suggest me the right things .:sign0085:
     

    Attached Files:

  8. agraham

    agraham Expert Licensed User

    I'm afraid you didn't, you saved it as an XLS file named tempad.csv.xls! Just naming it as a csv doesn't work. You need to do a File-> Save As and in the drop down list box next to "Save as type" select "CSV(MS-DOS) (*.csv)". Your version of Excel may differ slightly but the option will still be there.
     
  9. gjoisa

    gjoisa Active Member Licensed User

    Thank you agraham . It is working! I didnot know how to convert an MS Excel file to csv . You helped me very much . Thank you again .
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice