Hi Jon,
Though I don't have enough info, my first rewrite of your code is
if( tbl_Target.Rows.Count > 0 )
{
DataRow row_Target = tbl_Target.Rows[0];//Create row object to state
which row to work on.
row_Target.bBeginEdit();
foreach(DataColumn col_Source in tbl_Source.Columns) //Create column
object to go through each column in table (source).
{
if (row_Target.Tables.Columns.Contains(col_Source.ColumnName))
row_Target[col_Source.ColumnName] =
row_Source[col_Source.ColumnName];
}
row_Target.EndEdit();
da_Target.Update(ds_Target);
}
In this I assume that
tbl_Target is a DataTable drawn from ds_Target
you only want to UPDATE one row (the first) in tbl_Target with data from
one (the first) row in tbl_Source
there are no auto-incremental fields present
HTH
Christiaan
"Jon S via DotNetMonster.com" <u2272@uwe> schreef in bericht
news:55c60f9d0e34e@uwe...
> Hi all,
> I'm trying to update the target database with the data thats in the target
> dataset. I've included the snippit of code that is populating the target
> dataset. When I loop round I see the source dataset give data to the
> target
> dataset. I just don't know how to update the target database with the
> target
> dataset.
> Any help will be much appreciated???
> Thanks, Dan.
>
> if( tbl_Target.Rows.Count > -1 )
> {
> foreach(DataColumn col_Source in tbl_Source.Columns) //Create column
> object
> to go through each column in table (source).
> {
> DataRow row_Target = tbl_Target.Rows[0]; //Create row object to state
> which
> row to work on.
> string str_ColNameSource; //Variable to hold the name of each column.
> row_Target.BeginEdit();
> str_ColNameSource = col_Source.ColumnName;
> row_Target[str_ColNameSource] = row_Source[str_ColNameSource];
> row_Target.EndEdit();
> da_Target.Update(ds_Target, "Layouts");
> }
> }
>
>
> --
> Message posted via DotNetMonster.com
> http://www.dotnetmonster.com/Uwe/For...o-net/200510/1