DataAdapter to Update/Insert/Delete

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thesti
    New Member
    • Nov 2007
    • 144

    DataAdapter to Update/Insert/Delete

    hi,

    is it possible to execute stored procedure which will Insert/Update/Delete data in the database?

    Thank you.
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    A stored procedure can perform any of the sql actions you want to use.

    Comment

    • thesti
      New Member
      • Nov 2007
      • 144

      #3
      thanks for the reply,

      sorry i forgot to write DataAdapter, i mean is that is it possible to execute the Insert/Update/Delete storedProcedure by using DataAdapter?

      thanks

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        I've never tried it like that before, but assuming that those SPs take the right number of parameters then it should work. You can create new SqlCommand objects like so:
        Code:
        SqlCommand deleteCmd = new SqlCommand("sp_Delete",yourSqlConnection);
        SqlCommand.CommandType = CommandType.StoredProcedure;
        You'll probably have to add the parameters to the SP name and then define them.

        Comment

        Working...