How to copy DBF to SQL-import of DBF's table structure issue... -
09-13-2007
, 02:14 AM
The main question is the same as in the topic - I would like to import
information about DBF's table structure to some ArrayList instead of
writing it directly. I have _many_ tables to import...
I use OleDBConnection. Here is the code:
-------------------------------------------------------
public string connstr1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=";
public string connstr2 = ";Extended Properties=dBase III";
public DataSet GetFile(string path, string table, DataSet
myDataSet)
{
if (File.Exists(path + "\\" + table + ".DBF"))
{
OleDbConnection connection = new OleDbConnection(connstr1
+ path + connstr2);
connection.Open();
string query = "";
query = "SELECT * FROM " + table;
OleDbCommand dquery = new OleDbCommand(query, connection);
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.SelectCommand = new OleDbCommand(query,
connection);
adapter.Fill(myDataSet, table);
connection.Close();
}
else
{
LogIt(201, "Plik: " + path + "\\" + table + ".DBF nie
istnieje");
}
return myDataSet;
}
--------------------------------------
Can I receive it from the adapter or maybe the dataset?
Thank you in advance,
PiotreK |