Hi all,
 
Sorry for the cross posting.
 
I have a code that imports a csv file to the application to be used by ODBC driver to read the csv to the database, this works fine when I am using the local host on the development machine, but when i transfered the application to the web server, I start getting the following error:
 
ERROR [42000] [Microsoft][ODBC Text Driver] Syntax error in FROM clause.
 
When i Response.Write the file name, it came like this:
 
C:\TestProjects\\000872.csv
 
This is obviuosly the path to the file on the client machine, and the web application is running on the server machine, so how can I deal with this please?
 
Below is some more info, I have googled and looked at the following 2 links:
 
 
 
And my code is here:
 
 public DataSet CSV2DataSet(string strFileName)
  {
   DataSet ds = new DataSet();
   try
   {
    string ConnectionString =
     @"Driver={Microsoft Text Driver (*.txt; *.csv)};DBQ=c:\";
    System.Data.Odbc.OdbcConnection  conn = new System.Data.Odbc.OdbcConnection(ConnectionString);
    conn.Open(); 
    this.DisplayWebPageMessage(strFileName);
    System.Data.Odbc.OdbcDataAdapter da = new System.Data.Odbc.OdbcDataAdapter("Select * FROM " + strFileName, conn); 
    
    da.Fill(ds, "TheTable");
   
    //compMDMS objComponent = new compMDMS();
    
    conn.Close();
    return ds;
 
   }
   catch(System.Data.Odbc.OdbcException ex)
   {
    DisplayWebPageErrMessage(ex.Message);
    
   }
   return ds;
 

   /*
    string ConnectionString =
    ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
    "Data Source=" & "D:\My Documents\TextFiles" & ";" +
    "Extended Properties=""Text;HDR=NO;FMT=Delimited""";
 
    System.Data.OleDb.OleDbConnection TextConn = new System.Data.OleDb.OleDbConnection(ConnectionString);
    TextConn.Open();
    System.Data.OleDb.OleDbDataAdapter da =new System.Data.OleDb.OleDbDataAdapter("SELECT * FROM Test#csv", TextConn)
   */
   
      
 
 
 

  }
 
Thanks for your help and i look forward to your reply.

Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links

Reply via email to