0

Hi there,

The program in hand must retrieve a bunch of data from an SQL Database (currently stored in a DataTable), fiddle around with the data, and then upload the changed data to the same SQL database.

Everything works fine at the mo apart from the final bit, uploading to the database. This is my current effort at uploading the data:

foreach (DataRow row in statementResult.Rows)
                {
                    SQLDataAdapter.Update(row);
                {

The DataTable (statementResult) is created as follows:

DataTable statementResult = new DataTable();

SQLDataAdapter.Fill(statementResult);

So basically I am looking for a few tips to update the database with the new DataTable.

Any help is appreciated,

Cheers.

4
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by microdata
0

Since you are filling statementResult, and updating rows in statementResult and then you are using for each row loop for the same statementResult, why don't you update the datatable?

SQLDataAdapter.Update(statementResult)

0

Since you are filling statementResult, and updating rows in statementResult and then you are using for each row loop for the same statementResult, why don't you update the datatable?

SQLDataAdapter.Update(statementResult)

Thanks for the advice mate, got it working now :icon_smile:

0

i hAVE WROTE THIS CODE TO CAN UPDATE MY DATABASE:

        OleDbDataAdapter adp = new OleDbDataAdapter("SELECT * FROM " + dtName, conn);

        try
        {
            OleDbCommandBuilder mycmdbuilder = new OleDbCommandBuilder(adp);
            adp.Fill(dt);
            mycmdbuilder.GetUpdateCommand();
            mycmdbuilder.GetInsertCommand();
            mycmdbuilder.GetDeleteCommand();
            adp.Update(dt);


        }

AND I HAVE GOT THIS ERROR MESSAGE:
אין תמיכה ביצירת SQL דינאמי עבור UpdateCommand כנגד SelectCommand שאינה מחזירה כל מידע אודות עמודת מפתח.
CAN YOU HELP ME?? I WOULD THANK YOU!!!

Edited by mike_2000_17: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.