populating a db table with a sql dataset(full)
please can any one help....
i have a full dataset on the update line but when i do a select on the current table there is no data...
DataSet sqlDataSet = new DataSet();
//read fb tables into an array of 189 tables
DataSet fbDataSet = new DataSet();
for (int j = 33; j < 189; j++)
{
fbCommand.CommandText = "SELECT * FROM " + " " + tableNames[j] + ""; //actual table
FbDataAdapter fbAdapter2 = new FbDataAdapter(fbCommand);
string tableName = (string)tableNames[j];
fbAdapter2.Fill(fbDataSet, " " + tableName + "");
//sqlCommand.CommandText = "SELECT * FROM " + " " + tableNames[j] + "";
sqlDataSet = fbDataSet;
SqlDataAdapter sqlAdapter = new SqlDataAdapter("SELECT * FROM " + " " + tableNames[j] + "", sqlConnectionString);
if (sqlDataSet != null)
{
SqlCommandBuilder cb = new SqlCommandBuilder(sqlAdapter);
//sqlAdapter.UpdateCommand = cb.GetUpdateCommand();
sqlAdapter.TableMappings.Add("NONEXISTENTDATATABLE ", "" + tableName + "");
try
{
if (sqlDataSet.HasErrors == true)
{
sqlDataSet.RejectChanges();
MessageBox.Show("db write has errors");
}
else
{
sqlAdapter.Update(sqlDataSet,"NONEXISTENTDATATABLE "); // full dataset but not writing to my current table...
}
}
catch (Exception ex)
{
throw new System.Exception(" CANNOT WRITE SQL DB", ex);
}
}
}
|