olecon.Open();
DataSet newds = new DataSet();
try
{
OleDbCommandBuilder cmdbld = new OleDbCommandBuilder(oda);
cmdbld.SetAllValues = true;
oda.InsertCommand = cmdbld.GetInsertCommand();
ds.Tables[i].BeginLoadData();
int rowcount = ds.Tables[i].Rows.Count;
for (int n = 0; n < rowcount; n++)
{
ds.Tables[i].Rows[n].SetAdded();
}
oda.UpdateBatchSize = 1000;
}
catch
{
oda.Update(ds, ds.Tables[i].TableName);
oda.Dispose();
olecon.Dispose();
SqlBulkCopy sbc = new SqlBulkCopy(conn);
sbc.DestinationTableName = ds.Tables[i].TableName;
for (int q = 0; q < ds.Tables[i].Columns.Count; q++)
{
sbc.ColumnMappings.Add(ds.Tables[i].Columns[q].ColumnName, ds.Tables[i].Columns[q].ColumnName);
}
try
{
sbc.WriteToServer(ds.Tables[i]);
}
catch //(Exception ex)
{
//throw ex;
continue;
}
finally
{
ds.Dispose();
conn.Close();
sbc.Close();
}