Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. sqldataadapter. update

sqldataadapter. update

Scheduled Pinned Locked Moved ASP.NET
databaseannouncement
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sebastian T Xavier
    wrote on last edited by
    #1

    Hi, I would like to know how i can perform update or delete by using Update method of sql data adapter. I have done the insert operation using update method. The code follows... public Boolean SetStorageArea(int UID, DataTable dtStorageArea) { string strSql; strSql = "SELECT [Active],[WarehouseID],[StorageAreaID],[StorageAreaShortName],[StorageAreaName], " + " [Alias],[Notes],[CreatedBy],[CreatedOn],[LastModifiedBy],[LastModifiedOn] FROM [StorageArea]"; try { DataSet dsStorageArea = new DataSet(); dsStorageArea.Tables.Add(dtStorageArea); SqlDataAdapter sda = new SqlDataAdapter(strSql, sqlcon); SqlCommandBuilder sqb = new SqlCommandBuilder(sda); sda.Update(dsStorageArea, "StorageArea"); return true; } catch (Exception Ex) { throw new Exception("SetStorageArea: Could not get the records of all Storage Areas.\nOriginal message: " + Ex.Message); } } . awaiting for your valuable suggestions.. Thanks in advance Sebastian

    P 1 Reply Last reply
    0
    • S Sebastian T Xavier

      Hi, I would like to know how i can perform update or delete by using Update method of sql data adapter. I have done the insert operation using update method. The code follows... public Boolean SetStorageArea(int UID, DataTable dtStorageArea) { string strSql; strSql = "SELECT [Active],[WarehouseID],[StorageAreaID],[StorageAreaShortName],[StorageAreaName], " + " [Alias],[Notes],[CreatedBy],[CreatedOn],[LastModifiedBy],[LastModifiedOn] FROM [StorageArea]"; try { DataSet dsStorageArea = new DataSet(); dsStorageArea.Tables.Add(dtStorageArea); SqlDataAdapter sda = new SqlDataAdapter(strSql, sqlcon); SqlCommandBuilder sqb = new SqlCommandBuilder(sda); sda.Update(dsStorageArea, "StorageArea"); return true; } catch (Exception Ex) { throw new Exception("SetStorageArea: Could not get the records of all Storage Areas.\nOriginal message: " + Ex.Message); } } . awaiting for your valuable suggestions.. Thanks in advance Sebastian

      P Offline
      P Offline
      Pallavi Bhoite
      wrote on last edited by
      #2

      Hi Sebastian , I never used command builder ..i use sqlcommand object..check if it works for u ... SqlCommand updatecmd = new SqlCommand(strSql, sqlcon); SqlCommand deletecmd = new SqlCommand(strSql1, sqlcon); SqlCommand insertcmd = new SqlCommand(strSql2, sqlcon); SqlDataAdapter sda = new SqlDataAdapter(); sda.UpdateCommand = updatecmd; //here cmd generater for update sda.DeleteCommand = deletecmd; //here cmd generater for delete sda.InsertCommand = insertcmd ; //here cmd generater for insert sda.Update(dsStorageArea, "StorageArea");

      pallavi

      S 1 Reply Last reply
      0
      • P Pallavi Bhoite

        Hi Sebastian , I never used command builder ..i use sqlcommand object..check if it works for u ... SqlCommand updatecmd = new SqlCommand(strSql, sqlcon); SqlCommand deletecmd = new SqlCommand(strSql1, sqlcon); SqlCommand insertcmd = new SqlCommand(strSql2, sqlcon); SqlDataAdapter sda = new SqlDataAdapter(); sda.UpdateCommand = updatecmd; //here cmd generater for update sda.DeleteCommand = deletecmd; //here cmd generater for delete sda.InsertCommand = insertcmd ; //here cmd generater for insert sda.Update(dsStorageArea, "StorageArea");

        pallavi

        S Offline
        S Offline
        Sebastian T Xavier
        wrote on last edited by
        #3

        Hi Pallavi, Thank you very much. This method will work, the only thing is i have to avoid command builder... Thanks once again Sebastian

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups