Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I have a basic simple problem,i am trying to get the result of query executed or not when i try to insert a row into the database using dataadapter's fill method.
I know i can achieve the same using Connected Mode SqlCommand's ExecuteNonQuery method.
But i do not want to do that way , Is there any chance that i can get the result whether row has inserted into database or not using dataadapter's fill method ..
Below is my code.

C#
using (SqlDataAdapter da = new SqlDataAdapter("SomeInsertQuery"))
{
  using (DataSet ds = new DataSet())
   {
                                        
    da.Fill(ds);
//here i need to check whether insertion is successful or not so that i can display proper error message...

    if (!String.IsNullOrEmpty(successMsg))
    {  
      PSVMsgBox.ShowDALMsgBox(successMsg);
    }
                                        
   }
}
Thanks in Advance.
Posted
Updated 5-Mar-15 19:40pm
v4

1 solution

You should use DbDataAdapter.Update Method (DataSet)[^] instead of Fill.
Quote:
Return Value
Type: System.Int32
The number of rows successfully updated from the DataSet.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900