读固定格式文本文件 [英] Reading A Fixed Format Text File

查看:189
本文介绍了读固定格式文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它已经有好几年我不得不尝试使用Microsoft文本ODBC驱动程序或Microsoft的Jet OLE DB 4.0提供程序要读取的文件。

Its been years since I have had to attempt to read a file using either Microsoft Text ODBC Driver or Microsoft Jet OLE DB 4.0 Provider.

所以,我有以下代码

public void Example()
{
string CVS = Application.StartupPath;
string SQL = "SELECT * FROM [MyFile.txt]";
string Connection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+CVS+";"+"Extended Properties='text;HDR=Yes;FMT=Fixed;";
OleDbDataAdapter OLE = new OleDbDataAdapter(SQL,Connection);
DataTable Table = new DataTable();
OLE.Fill(Table);
}

当我运行上面的代码中,我得到一个意外的错误,我知道我失去了一些东西,我不知道究竟是什么

When I run the above code I get an "Unexpected Error", I know I am missing something, I am not sure what exactly.

来源:

http://www.connectionstrings.com/textfile 结果
http://www.connectionstrings.com/Providers/net-framework-data-provider-for-ole- DB 结果
http://www.aspdotnetcodes.com/Importing_CSV_Database_Schema .ini.aspx 结果

任何方向将不胜感激。

让我们假设Schema.ini文件是正确的。它拥有30和60长度的文本值。我会提供的文件,如果要求

Let us assume the Schema.ini file is correct. It has 30 and 60 length text values. I will provide the document if requested.

推荐答案

删除(只是之前的'文本)。从连接字符串

Remove ' (just prior to 'text;) from the connection string.

在为了解决找不到可安装ISAM,运行以下命令:
Regsvr32的C:\winnt\system32\mstext40.dll
*确保文件是该文件夹中的第一。并改变WINNT到任何你的windows目录。

In order to resolve the "Could not find installable ISAM", run the following command: Regsvr32 c:\winnt\system32\mstext40.dll * Make sure that file is in that folder first. And change WINNT to whatever your windows directory is.

这篇关于读固定格式文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆