Connectionstring RRS feed

  • Question

  • User-1538551077 posted
    Hi all, I'm getting error like this ERROR [42S02] [Microsoft][ODBC Text Driver] The Microsoft Jet database engine could not find the object 'TaskExport.csv'. Make sure the object exists and that you spell its name and the path name correctly. Pls give a solution for this Thanks My code string ExcelFilename = FileUpload1.PostedFile.FileName; DataSet ds = new DataSet(); string mystr = Server.MapPath("Imported Files/"); string constring = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + mystr + ";Extensions=asc,csv,tab,txt;"; writeSchema(); OdbcConnection conn1 = new OdbcConnection(constring); string sql = "select * from [" + ExcelFilename + "]"; conn1.Open(); System.Data.Odbc.OdbcDataAdapter adpt = new System.Data.Odbc.OdbcDataAdapter(sql, conn1); adpt.Fill(ds, "ds"); conn1.Close();
    Monday, February 2, 2009 2:22 AM


All replies

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 2, 2009 9:26 AM
  • User-319574463 posted

     To make your code easier to follow, please do the following:

    • Click on Edit Profile (top right hand corner)
    • Click on the "Site Options Tab"
    • Change Content Editor to "Enhanced"
    • Click Save
    • When you next respond or create or edit a thread, you will have an additional toolbar
    • The rightmost button on the top toolbar allows for unmangled code entry:
    • You can also now set the font to for example Courier New
    Monday, February 9, 2009 5:28 AM
  • User-319574463 posted

     You should investigate what the connection string should be like:

    1) Create an empty text file in windows explorer and rename it to X.UDL
    2) Double click on it and the data-link provider dialogue will appear.
    3) Select the provider tab. Find the provider for Access  and click next.
    4) Select your database
    5) Test the connection and save it.
    6) Compare the contents of X.UDL with your connections string.

    You could try looking on http://www.connectionstrings.com/ for an Access example.

    Monday, February 9, 2009 5:31 AM