Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 5th, 2006, 07:14 PM
Registered User
 
Join Date: Jan 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Read DBase IV file with other extension(.dbf)

I'm trying to read the DBase file in WebForm.
I have succeed in doing that only if that file has *.dbf extension and the filename is shorter than 8 characters with either of these 2 methods

Code:
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("DBaseFile/")+";Extended Properties=DBase IV;";
OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM test.dbf",strConn);
DataSet myDataSet = new DataSet();
myCommand.Fill(myDataSet);
DataGrid1.DataSource = myDataSet.Tables[0].DefaultView;
DataGrid1.DataBind();
or
Code:
OdbcConnection conn = new OdbcConnection();
conn.ConnectionString = "Driver={Microsoft dBASE Driver (*.dbf)};" + 
"DriverID=277;" + 
"Dbq="+Server.MapPath("DBaseFile/");
OdbcDataAdapter adapter = new OdbcDataAdapter();
adapter.SelectCommand = new OdbcCommand("Select * FROM [test.dbf]", conn);
adapter.Fill(myDataSet);
DataGrid1.DataSource = myDataSet.Tables[0].DefaultView;
DataGrid1.DataBind();
but the above code do not work when the file name of the dbase file is longer than 8 characters or if the extension of dbase file is something else ( any arbitary extension, eg: test.abc)
is there anyway to get around this without first rename my dbase file to the correct format?
because my program will process lots of 3rd party dbase files so it will slow down the process a lot if i need to rename all those files.

Thank You

 
Old January 9th, 2006, 05:56 AM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nalla Send a message via Yahoo to nalla
Default



Hi,

It should work. Create a DSN using Microsoft Visual Foxpro driver.
Use "MSDASQL.1;Persist Security Info=False;Data Source=DSN_NAME" as your connection string and give your file extension correctly in your SQLs.

DSN_NAME - Created DSN name

nalla








Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I read a DBF file rtr1900 Classic ASP Databases 2 August 13th, 2007 12:36 PM
How to connect to a dbf file using VBA? smartmani VB How-To 0 June 17th, 2005 04:39 PM
SQL Server: Copy Table From dbase to other dbase orez SQL Server 2000 3 July 7th, 2004 03:51 AM
ADO connection string to dBase IV EddyT Excel VBA 2 June 21st, 2004 02:59 AM
How to Use foxpro's DBF file cbpanchal VB How-To 0 September 12th, 2003 03:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.