none
don't login OLE DB Access Interface "MSDASQL" RRS feed

  • 问题

  • help me!!!

    there is a problem:

    don't login OLE DB Access Interface "MSDASQL"

    my code is:

    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString);
            string SQL = @"insert text select *  from   OpenRowset( 'MSDASQL ','Driver={Microsoft Text Driver (*.txt;*.csv)};DefaultDir=c:\; ','select * from aa.txt ') ";
            conn.Open();
            SqlCommand cmd = new SqlCommand(SQL,conn);
            cmd.ExecuteNonQuery();
            conn.Close();

    I want read aa.txt's content to Sql table text.

    I think the wrong is the connection string,but I don't know who to rework it

    thank you!

    2008年6月17日 15:12

答案

  •  

    参考

    Code Snippet
    ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(".") + ";Extended Properties=\"Text;HDR=yes;FMT=Delimited\"";
     SQLString = "Select * from ReportFile.txt";
     System.Data.OleDb.OleDbConnection ConnectionText = new System.Data.OleDb.OleDbConnection();
     ConnectionText.ConnectionString = ConnectionString;
     ConnectionText.Open();
     System.Data.OleDb.OleDbDataAdapter AdapterText = new System.Data.OleDb.OleDbDataAdapter(SQLString, ConnectionText);
     System.Data.DataSet DataSetText = new System.Data.DataSet("TextFiles");
     AdapterText.Fill(DataSetText, "TextFile");

     

     


    http://blog.csdn.net/net_lover/archive/2005/06/13/393579.aspx
    2008年6月18日 0:18
    版主
  • thank you for help me ,I think your answer is right,but  this is not  what  I need.thank  you all ther

    same!
    2008年6月19日 14:02

全部回复

  •  

    参考

    Code Snippet
    ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(".") + ";Extended Properties=\"Text;HDR=yes;FMT=Delimited\"";
     SQLString = "Select * from ReportFile.txt";
     System.Data.OleDb.OleDbConnection ConnectionText = new System.Data.OleDb.OleDbConnection();
     ConnectionText.ConnectionString = ConnectionString;
     ConnectionText.Open();
     System.Data.OleDb.OleDbDataAdapter AdapterText = new System.Data.OleDb.OleDbDataAdapter(SQLString, ConnectionText);
     System.Data.DataSet DataSetText = new System.Data.DataSet("TextFiles");
     AdapterText.Fill(DataSetText, "TextFile");

     

     


    http://blog.csdn.net/net_lover/archive/2005/06/13/393579.aspx
    2008年6月18日 0:18
    版主
  • thank you for help me ,I think your answer is right,but  this is not  what  I need.thank  you all ther

    same!
    2008年6月19日 14:02