问题描述
我之前连接到过 foxpro 数据库,但只有同时具有 .dbf 和 .idx 文件的数据库.
I've connected to foxpro databases before, but only ones that have both a .dbf and .idx file.
我注册了 Microsoft Ole DB Provider for Visual Foxpro 7.0 并使用以下类型的代码:
I register the Microsoft Ole DB Provider for Visual Foxpro 7.0 and use the following type of code:
string sqlSTR = "SELECT * FROM TableName";
string strConnect = @"Provider=VFPOLEDB.1;Data Source=C:\Stuff.dbf;Extended Properties=dBASE IV;"
并打开连接.但是,该文件具有 .dbf 和 .cdx 文件(在线阅读似乎是数据库的结构).当我使用上面的连接字符串和以下代码时:
And open the connection. This file, though, has a .dbf and .cdx file (which, reading online seems to be the structure of the database). When I use the connection string above and the following code:
OleDbConnection myConn = new OleDbConnection(strConnect);
myConn.Open()
它没有错误或任何东西,但程序的执行在这里挂起.我有同一个程序的其他几个部分,它们连接到存在 dbf + idx 文件(不是 cdx)的文件.我做错了什么需要纠正?
It doesn't error or anything, but the execution of the program hangs here. I have several other parts of the same program that are connecting to files with a dbf + idx file present (not cdx). What am I doing wrong that I need to correct?
我使用 sqlSTR 使用数据适配器 btw 进行后续操作.
I use the sqlSTR for later operations using a data adapter btw.
推荐答案
您的连接字符串错误.应该是这样的:
Your connection string is wrong. It should be like:
string sqlSTR = "SELECT * FROM TableName";
string strConnect = @"Provider=VFPOLEDB;Data Source=C:\;"
使用 c:\ 作为数据库文件(或其他文件)的位置是有问题的.
Using c:\ as a location for database files (or other files) is questionable.
这篇关于C# VFP OLEDB 连接字符串问题(DBF 和 CDX 与 DBF 和 IDX)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!