private void Form1_Load(object sender, EventArgs e)
{
GetDataTable(@"C:\Documents and Settings\agordon\Desktop\ACTIVITYEX.log");
}
public System.Data.DataTable GetDataTable(string strFileName)
{
System.Data.OleDb.OleDbConnection conn =
new System.Data.OleDb.OleDbConnection
("Provider=Microsoft.Jet.OleDb.4.0; Data Source = "
+ System.IO.Path.GetDirectoryName(strFileName)
+ ";Extended Properties = \"Text;HDR=YES;FMT=TabDelimited\"");
conn.Open();
string strQuery = "SELECT * FROM [" + System.IO.Path.GetFileName(strFileName) + "]";
System.Data.OleDb.OleDbDataAdapter adapter = new System.Data.OleDb.OleDbDataAdapter(strQuery, conn);
System.Data.DataTable ds = new System.Data.DataTable("CSV File");
adapter.Fill(ds);
return ds;
}
當同一個文件被命名爲.csv
它不會給我一個錯誤;但是當我將它重命名爲.log
它說Cannot update. Database or object is read-only.
上adapter.Fill
c#datatable無法更新。數據庫或對象是隻讀的
這是一個編譯器錯誤?
注意解釋投票嗎? – ChrisWue 2011-06-02 03:38:32