I'm exporting data from sqlserver into a text file. I don't want to use a
linked server or DTS.
I have no problem getting the data into the correct dataset (the dataset
linked to the text file), but for some reson the text file is not written to
durring the update. Please help.
..
..
..
OleDbDataAdapter edapt = new OleDbDataAdapter(exml.Sql,econn); // passing
connection to text file
OleDbDataAdapter dapt = new OleDbDataAdapter(xml.Sql,conn);// passing
connection to sqlserver
OleDbCommandBuilder ecb = new OleDbCommandBuilder(edapt);
ecb.QuotePrefix = "[";
ecb.QuoteSuffix = "]";
DataSet edset = new DataSet();// text dataset
DataSet dset = new DataSet();//sqlserver dataset
try
{
edapt.Fill(edset,exml.Catalog);
edset.Tables[exml.Catalog].Columns["machine_Key"].Unique = true;
ecb.RefreshSchema();
Console.WriteLine(edset.GetXml()); //empty
dapt.Fill(dset,exml.Catalog);
edset.Merge(dset,true,System.Data.MissingSchemaAct ion.Add);
//Console.WriteLine("\n\n\n" + edset.GetXml()); //full - therefore, data
was merged
edset.AcceptChanges();
edapt.Update(edset,exml.Catalog);
Console.WriteLine(ecb.GetInsertCommand().CommandTe xt); // looks good
edset.Dispose();
dset.Dispose();
ecb.Dispose();
}
catch( Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
}