是否可以在 .Net 应用程序中读取 Paradox 7.x .db 文件?

发布于 2024-07-14 04:35:36 字数 769 浏览 5 评论 0原文

我正在尝试在 .Net 3.5 应用程序中读取 Paradox 7.x .db 文件,但没有成功。

首先,当我将 odbc 注册为用户或系统 dsn 时,Microsoft Paradox ODBC 驱动程序仅显示最高 5.x 的版本,因此看起来它不支持 Paradox 版本 7.x。

connectionsstrings.com 我找到了应该与 Paradox 7.x 一起使用的连接字符串:

Provider=MSDASQL;Persist Security Info=False;Mode=Read;
Extended Properties='DSN=Paradox;DBQ=C:\mydbfolder;
DefaultDir=C:\mydbfolder;DriverId=538;FIL=Paradox 7.X;MaxBufferSize=2048;
PageTimeout=600;';Initial Catalog=C:\mydbfolder

但是,当我尝试使用数据适配器测试连接时,出现以下异常:

“错误 [IM002] [Microsoft][ODBC 驱动程序管理器] 未找到数据源名称且未指定默认驱动程序”

我已将 ODBC 指定为用户DSN 和系统 DSN 也是如此,但不断收到相同的错误。

关于我应该做什么的任何线索?

谢谢,

佩德罗

I'm trying to read a Paradox 7.x .db file in a .Net 3.5 app and I'm not being successful on that.

First of all, when I'm registering the odbc, as a user or system dsn, the Microsoft Paradox ODBC Driver only display versions up to 5.x, so it looks like that it does not support Paradox version 7.x.

At connectionsstrings.com I've found the connection string that is supposed to work with Paradox 7.x:

Provider=MSDASQL;Persist Security Info=False;Mode=Read;
Extended Properties='DSN=Paradox;DBQ=C:\mydbfolder;
DefaultDir=C:\mydbfolder;DriverId=538;FIL=Paradox 7.X;MaxBufferSize=2048;
PageTimeout=600;';Initial Catalog=C:\mydbfolder

But when I try to test the connection using a Data Adapter I get the following exception:

"ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"

I have specified the ODBC as a user DSN and as a System DSN as well but kept receiving the same error.

Any clues on what should I do?

Thanks,

Pedro

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

喜爱纠缠 2024-07-21 04:35:36

http: //www.progware.org/Blog/post/Connecting-to-a-PARADOX-DB-with-C-%28Vista-XP%29.aspx

ConnectionString.Append(@"Provider=Microsoft.Jet.OLEDB.4.0;");
ConnectionString.Append(@"Extended Properties=Paradox 7.x;");
ConnectionString.Append(@"Data Source=Z:\Dane;");
//ConnectionString.Append(@"Mode=ReadWrite;");
ConnectionString.Append(@"Mode=1;");

http://www.progware.org/Blog/post/Connecting-to-a-PARADOX-DB-with-C-%28Vista-XP%29.aspx

and

ConnectionString.Append(@"Provider=Microsoft.Jet.OLEDB.4.0;");
ConnectionString.Append(@"Extended Properties=Paradox 7.x;");
ConnectionString.Append(@"Data Source=Z:\Dane;");
//ConnectionString.Append(@"Mode=ReadWrite;");
ConnectionString.Append(@"Mode=1;");
攒一口袋星星 2024-07-21 04:35:36

好奇,为什么不使用 OLEDB 提供程序,然后使用 System.Data.OleDb 名称空间中的类?

Curious, why not use the OLEDB provider and then use the classes in the System.Data.OleDb namepsace?

枫林﹌晚霞¤ 2024-07-21 04:35:36

这是我过去编写的一段代码,它可以工作。 它基于 Przemysław Staniszewski 在本线程其他地方的帖子中现已失效的链接中的代码。

它使用 OleDbConnection 和 OleDbDataAdapter 打开一个 Paradox 数据库文件,并将该文件的内容加载到 DataTable 变量中。

这段代码适用于我,用于紧急的一次性作业,并且缺乏错误处理。 也许对你有用。

        /// <summary>
        /// ConnectToTable
        /// </summary>
        /// <param name="pFullPath">Full path to .DB file</param>
        /// <param name="pTableName">Name of table to load</param>
        public static void ConnectToTable(string pFullPath, string pTableName)
        {

            OleDbConnection _ParadoxConnection = new OleDbConnection();

            StringBuilder ConnectionString = new StringBuilder("");
            ConnectionString.Append(@"Provider=Microsoft.Jet.OLEDB.4.0;");
            ConnectionString.Append(@"Extended Properties=Paradox 7.x;");
            ConnectionString.Append(string.Format(@"Data Source={0}", pFullPath));

            _ParadoxConnection.ConnectionString = ConnectionString.ToString();

            _ParadoxConnection.Open();

            using (OleDbDataAdapter da = new OleDbDataAdapter(
                string.Format("SELECT * FROM {0};", pTableName)
                , _ParadoxConnection))
            {
                DataTable tab = new DataTable
                {
                    TableName = pTableName
                };
                da.Fill(tab);

                //tab now contains a data

                //Get the column name
                foreach(DataColumn col in tab.Columns)
                {
                    Console.WriteLine(col.ColumnName);
                }

                //do the rows
                foreach (DataRow row in tab.Rows)
                {
                    foreach(var item in row.ItemArray)
                    {
                        //write each row value
                    }
                }
            }
        }

Here is a piece of code I've worked on in the past that will work. It is based on code from the now dead link in Przemysław Staniszewski's post elsewhere in this thread.

It opens a paradox database file using and OleDbConnection and OleDbDataAdapter, and loads the contents of that file into a DataTable variable.

This code works for me, and was used for a rushed oneshot job, and lacks error handling. It maybe of use to you.

        /// <summary>
        /// ConnectToTable
        /// </summary>
        /// <param name="pFullPath">Full path to .DB file</param>
        /// <param name="pTableName">Name of table to load</param>
        public static void ConnectToTable(string pFullPath, string pTableName)
        {

            OleDbConnection _ParadoxConnection = new OleDbConnection();

            StringBuilder ConnectionString = new StringBuilder("");
            ConnectionString.Append(@"Provider=Microsoft.Jet.OLEDB.4.0;");
            ConnectionString.Append(@"Extended Properties=Paradox 7.x;");
            ConnectionString.Append(string.Format(@"Data Source={0}", pFullPath));

            _ParadoxConnection.ConnectionString = ConnectionString.ToString();

            _ParadoxConnection.Open();

            using (OleDbDataAdapter da = new OleDbDataAdapter(
                string.Format("SELECT * FROM {0};", pTableName)
                , _ParadoxConnection))
            {
                DataTable tab = new DataTable
                {
                    TableName = pTableName
                };
                da.Fill(tab);

                //tab now contains a data

                //Get the column name
                foreach(DataColumn col in tab.Columns)
                {
                    Console.WriteLine(col.ColumnName);
                }

                //do the rows
                foreach (DataRow row in tab.Rows)
                {
                    foreach(var item in row.ItemArray)
                    {
                        //write each row value
                    }
                }
            }
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文