开发者

How to manipulate .dbf files using c#?

I am trying to something like this:

        string pathFiles = Path.Combine(Application.StartupPath, "DB");
        string strconn = "Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;" +
               "Dbq="+pathFiles+";";                      
        OdbcConnection odbconn = new OdbcConnection(strconn);
        odbconn.Open();

and i get this exception

ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no de开发者_StackOverflow社区fault driver specified

The problem is that the same code runs ok on windiws XP , visual studio 2010, office 2007 and it doesn't work on windows 7 64bit , visual studio 2008,office 2010. I really don't know whatvis the difference, i am new to win 7. Some tips would be great.Thanks.


For what it is worth, I manipulate dBase files using the following connection on Vista and Windows 7. I still set the target output as x86.

using (OleDbConnection connection = new OleDbConnection(string.Format("Provider=Microsoft.JET.OLEDB.4.0;" +
    "Data Source={0};Extended Properties=dBase IV;", Path.Combine(Environment.CurrentDirectory, OutputFolderName))))
{
    //....
    //....
}

The output folder name is just the directory where the DBase files that I'm either writing to or reading from.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜