Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, December 8, 2016 7:05 AM
Please it would be very appreciate if anybody can help me with a code to export records from the dataset / datatable into a dbf file .
Regards
Pol
polachan
All replies (9)
Thursday, December 8, 2016 9:37 AM | 1 vote
Hello,
You need to setup a proper connection string first e.g.
https://www.connectionstrings.com/dbf-foxpro/
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\folder;
Extended Properties=dBASE IV;User ID=Admin;Password=;
Or
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\folder;
Extended Properties=dBase III;User ID=Admin;Password=;
Setup an OleDb connection and command, setup parameters for the command. From here loop thru a table in the data set using SQL INSERT statement setup in the command object insert rows.
Now there is no guarantee this will work even though the direction is right. I would suggest backing up the DBF before starting to attempt inserts.
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
VB Forums - moderator
Thursday, December 8, 2016 9:55 AM | 1 vote
Hi polachan,
Thank you for posting here.
For your question, please try the following code.
OleDbConnection conn;
OleDbCommand cmd;
OleDbDataReader dr;
string sqlStr = "";
DataSet myDataSet;
OleDbDataAdapter myAdapter;
conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\Data\\DBF\\;Extended Properties=DBASE IV;");
conn.Open();
sqlStr = "Select * from testdbf.dbf";
//Make a DataSet object
myDataSet = new DataSet();
//Using the OleDbDataAdapter execute the query
myAdapter = new OleDbDataAdapter(sqlStr, conn);
//Build the Update and Delete SQL Statements
OleDbCommandBuilder myBuilder = new OleDbCommandBuilder(myAdapter);
//Fill the DataSet with the Table
myAdapter.Fill(myDataSet, "somename");
I hope this would be helpful to you.
If you have something else, please feel free to contact us.
Best Regards,
Wendy
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].
Thursday, December 8, 2016 11:12 AM
Please it would be very appreciate if anybody can help me with a code to export records from the dataset / datatable into a dbf file .
2 first Google links :
http://stackoverflow.com/questions/322792/how-can-i-save-a-datatable-to-a-dbf
http://stackoverflow.com/questions/32578233/create-dbf-file-from-sql-table-records
Thursday, December 8, 2016 12:06 PM
Many are replying to you.
However, what do you mean with a DataSet or DataTable.
It is an object inside a C# program, which says as much as "an interieur"
A DBF file is a kind of database file. Can be DbaseIII, DbaseIV or Foxpro. In this context it says as much as a city.
Therefore your questions sounds like Export furniture from the interieur to a City
Be more precise what you want to achieve?
Success
Cor
Thursday, December 8, 2016 12:35 PM
Your answer is diffrent from my question . I would like to export records from sqlserver database datatable into dbf file .
Anyway Thanks
Regards
Pol
polachan
Thursday, December 8, 2016 12:45 PM
Your answer is diffrent from my question . I would like to export records from sqlserver database datatable into dbf file .
Anyway Thanks
Stackoverflow samples do exactly this...
Thursday, December 8, 2016 12:50 PM
Your answer is diffrent from my question . I would like to export records from sqlserver database datatable into dbf file .
Anyway Thanks
Regards
Pol
polachan
Maybe I get problems with my eyes but you wrote
export records from the dataset / datatable
That is complete different from what you write now.
Maybe you mean export from a SQL Server Table into a DBF file.
(But then you have to tell of the table exist already in the DBF file)
Success
Cor
Thursday, December 8, 2016 2:13 PM
Your answer is diffrent from my question . I would like to export records from sqlserver database datatable into dbf file .
Anyway Thanks
Regards
Pol
polachan
Can the export be done directly to the dBase file or do you need to put it in a DataSet first?
Paul ~~~~ Microsoft MVP (Visual Basic)
Wednesday, December 14, 2016 3:28 PM
Hi polchan,
If your issue is solved please Mark as answer or Vote as helpful post to the appropriate answer so that it will help other members to find solution if they faces similar issue.
Thanks,
Sabah Shariq
[If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]