In MSSQL, how to know update query will affect any rows or not.
-
Hi all, I am trying to update a row through update query using SqlDataAdapter and DataSet. How can I know, this update query has made any changes in any row or not? Thanks and Regards.
SqlDataAdapter.Update(DataSet) returns an System.Int32 value which gives the number of rows successfully updated from the DataSet.
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)
-
Hi all, I am trying to update a row through update query using SqlDataAdapter and DataSet. How can I know, this update query has made any changes in any row or not? Thanks and Regards.
Hi............. Its Simple.... Just Keep the return value.... if it zero ... then No change.... else thats much change.... Just click If u wantto Know more... http://msdn.microsoft.com/en-us/library/at8a576f.aspx\[^\]
-
SqlDataAdapter.Update(DataSet) returns an System.Int32 value which gives the number of rows successfully updated from the DataSet.
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)
-
Hi............. Its Simple.... Just Keep the return value.... if it zero ... then No change.... else thats much change.... Just click If u wantto Know more... http://msdn.microsoft.com/en-us/library/at8a576f.aspx\[^\]
-
Thanks for your reply but I can not understand how to use this. I am using given refrence link but it fires an exception (Update unable to find TableMapping['Table'] or DataTable 'Table'.).
It sounds like the basic issue is one of incompetence. Have you looked at the link provided and the code in the MSDN and compared it to your own ? If you want us to fix your code, have you considered posting it, so we can see where your error is ?
Christian Graus Driven to the arms of OSX by Vista.
-
Thanks for your reply but it can't work or I can not understand how to use this. Please describe with a little example. It fires an exception (Update unable to find TableMapping['Table'] or DataTable 'Table'.).
Use the Update overloaded one...i mean
SqlAdapter sa = new SqlAdapter();
//Provide the command name or all the required stuff
//Call Update(DataSet dataset, string srctable)
int j = sa.Update(ds,"TableName"); ///j contains the number of rows updated.
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)
-
It sounds like the basic issue is one of incompetence. Have you looked at the link provided and the code in the MSDN and compared it to your own ? If you want us to fix your code, have you considered posting it, so we can see where your error is ?
Christian Graus Driven to the arms of OSX by Vista.
This is my code, where the problem occurs. SqlDataAdapter da = new SqlDataAdapter("UPDATE CompanyInfo SET CompName='abc' where CompID='" + CompID.Text.Trim() + "'", con); DataSet ds = new DataSet(); da.Fill(ds); int gh = da.Update(ds, "CompanyInfo"); Exception fires on that code is ("Update unable to find TableMapping['CompanyInfo'] or DataTable 'CompanyInfo'."). Please suggest for the wrong code. Thanks and Regards