B
Bartosz Matuszczak
Hi
I need to track any changes of rows in my database. I do this by filling in
a loop dataset to have newest data from data source.
Moreover I want to know which data has been modifed in database. I refresh
dataset every second and i fill it up with datadapter. It's working but i
don't know which rows has been modified. I add second dataset to help me do
that. Please look at this short code:
....
SqlDataAdapter myAdapter= new SqlDataAdapter();
myAdapter.SelectCommand = objCommand;
DataSet myDataSet= new DataSet();
DataSet myTmpDataSet= new DataSet();
myAdapter.FillSchema(myDataSet,SchemaType.Mapped);
myAdapter.FillSchema(myTmpDataSet,SchemaType.Mapped);
while (true)
{
myAdapter.Fill(myTmpDataSet);
myDataSet.Merge(myTmpDataSet,false);
if(myDataSet.HasChanges())
{
System.Console.WriteLine("Some data has been
changed");
// myDataSet.GetChanges() should give me dataset
only with changed data in datasource
}
System.Threading.Thread.Sleep(1000);
myDataSet.AcceptChanges();
}
Merge refresh myDataSet with new values comming from data source, but
function HasChanges is always false. I know that is true when i change
dataset , not data source. Is there any solution that help me to have
"fresh" data set and to know what data has been changed in data source and
when? Changes occurs only in the database not in dataset.
Thanks Bartek
I need to track any changes of rows in my database. I do this by filling in
a loop dataset to have newest data from data source.
Moreover I want to know which data has been modifed in database. I refresh
dataset every second and i fill it up with datadapter. It's working but i
don't know which rows has been modified. I add second dataset to help me do
that. Please look at this short code:
....
SqlDataAdapter myAdapter= new SqlDataAdapter();
myAdapter.SelectCommand = objCommand;
DataSet myDataSet= new DataSet();
DataSet myTmpDataSet= new DataSet();
myAdapter.FillSchema(myDataSet,SchemaType.Mapped);
myAdapter.FillSchema(myTmpDataSet,SchemaType.Mapped);
while (true)
{
myAdapter.Fill(myTmpDataSet);
myDataSet.Merge(myTmpDataSet,false);
if(myDataSet.HasChanges())
{
System.Console.WriteLine("Some data has been
changed");
// myDataSet.GetChanges() should give me dataset
only with changed data in datasource
}
System.Threading.Thread.Sleep(1000);
myDataSet.AcceptChanges();
}
Merge refresh myDataSet with new values comming from data source, but
function HasChanges is always false. I know that is true when i change
dataset , not data source. Is there any solution that help me to have
"fresh" data set and to know what data has been changed in data source and
when? Changes occurs only in the database not in dataset.
Thanks Bartek