【发布时间】:2015-04-15 20:31:24
【问题描述】:
更新 1: 我认为 schema.ini 不正确。请参考以下问题。 文件 (dsTextFile) 只有一行数据,但记录数为零。所以这意味着它根本没有阅读。这是完全删除 FMT 或使用 Delim。如果 FMT 已修复,我仍然会收到错误消息。那么,如何创建 SCHEMA.ini 或确保 schema.ini 正确?
private bool LoadTextFile(string textFilePath, out string errorInfo) {
errorInfo = String.Empty;
try {
string textFileFolder = (new System.IO.FileInfo(textFilePath)).DirectoryName;
string textConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + textFileFolder + ";" +
"Extended Properties=\"text;HDR=No;FMT=Fixed\";";
OleDbConnection textConnection = new OleDbConnection(textConnectionString);
textConnection.Open();
textFilePath = (new System.IO.FileInfo(textFilePath)).Name;
string selectCommand = "select * from " + textFilePath;
OleDbCommand textOpenCommand = new OleDbCommand(selectCommand);
textOpenCommand.Connection = textConnection;
OleDbDataAdapter textDataAdapter = new OleDbDataAdapter(textOpenCommand);
Console.WriteLine("Trying to set textDataAdapter");
int rows = textDataAdapter.Fill(dsTextFile); //This is where error is coming.
Console.WriteLine("detail rows being filled");
textConnection.Close();
textConnection.Dispose();
return true;
}
catch (Exception ex_load_text_file) {
Console.WriteLine("error in loadTextFile is " + ex_load_text_file.Message.ToString());
return false;
}
}
请在下面的行中找到错误“未指定”的上述来源。
UnSpecified 错误出现在下面一行
int rows = textDataAdapter.Fill(dsTextFile)
可能是什么问题?我检查了 c:\windows\temp 上的用户权限,但没有成功。
这是一个控制台应用程序,我什至尝试在 app.config 中添加以下代码,但还没有成功。
<system.web>
<identity imperonate = "false"/> </system.web>
这是一个旧版应用程序,但需要在 windows server 2012 安装程序上运行。
【问题讨论】:
标签: asp.net console-application impersonation jet oledbdataadapter