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. Database & SysAdmin
  3. Database
  4. dataAdapter update problem

dataAdapter update problem

Scheduled Pinned Locked Moved Database
databasehelpannouncement
3 Posts 3 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.
  • P Offline
    P Offline
    PJ Intellia
    wrote on last edited by
    #1

    Hi, I have some strange problems with the update of a dataadapter. First, I read a row in a table, through a dataset : da = New SqlDataAdapter(sql, conn) ds = New DataSet da.Fill(ds, "MyTable") da.SelectCommand.CommandText = "select * from address" Dim sqlBuilder As SqlCommandBuilder = New SqlCommandBuilder(da) da.InsertCommand = sqlBuilder.GetInsertCommand() da.DeleteCommand = sqlBuilder.GetDeleteCommand() da.UpdateCommand = sqlBuilder.GetUpdateCommand() ta = ds.Tables("MyTable") pka(0) = ta.Columns("address_id") ta.PrimaryKey = pka dim dr As DataRow dr = ta.Rows.Find(1) 'get the address with id 1 Then I update a field : dr("country_id") = system.dbnull.value and now I commit the change : da.update(ds) But changes are not reflected in the database.... The update command doesn't work with this update. If country_id value is not null, it works... I precise that country_id is nullable in the DB. Thanks for any help. Best regards. Arthur

    S S 2 Replies Last reply
    0
    • P PJ Intellia

      Hi, I have some strange problems with the update of a dataadapter. First, I read a row in a table, through a dataset : da = New SqlDataAdapter(sql, conn) ds = New DataSet da.Fill(ds, "MyTable") da.SelectCommand.CommandText = "select * from address" Dim sqlBuilder As SqlCommandBuilder = New SqlCommandBuilder(da) da.InsertCommand = sqlBuilder.GetInsertCommand() da.DeleteCommand = sqlBuilder.GetDeleteCommand() da.UpdateCommand = sqlBuilder.GetUpdateCommand() ta = ds.Tables("MyTable") pka(0) = ta.Columns("address_id") ta.PrimaryKey = pka dim dr As DataRow dr = ta.Rows.Find(1) 'get the address with id 1 Then I update a field : dr("country_id") = system.dbnull.value and now I commit the change : da.update(ds) But changes are not reflected in the database.... The update command doesn't work with this update. If country_id value is not null, it works... I precise that country_id is nullable in the DB. Thanks for any help. Best regards. Arthur

      S Offline
      S Offline
      sreejith ss nair
      wrote on last edited by
      #2

      See some senario we can't predict that user will give correct, valid data. So i recommand you to define an update,delete command by yourself and execute the command. And assign this defined queary to respective delete,update command of your data adapter Sreejith Nair [ My Articles ]

      1 Reply Last reply
      0
      • P PJ Intellia

        Hi, I have some strange problems with the update of a dataadapter. First, I read a row in a table, through a dataset : da = New SqlDataAdapter(sql, conn) ds = New DataSet da.Fill(ds, "MyTable") da.SelectCommand.CommandText = "select * from address" Dim sqlBuilder As SqlCommandBuilder = New SqlCommandBuilder(da) da.InsertCommand = sqlBuilder.GetInsertCommand() da.DeleteCommand = sqlBuilder.GetDeleteCommand() da.UpdateCommand = sqlBuilder.GetUpdateCommand() ta = ds.Tables("MyTable") pka(0) = ta.Columns("address_id") ta.PrimaryKey = pka dim dr As DataRow dr = ta.Rows.Find(1) 'get the address with id 1 Then I update a field : dr("country_id") = system.dbnull.value and now I commit the change : da.update(ds) But changes are not reflected in the database.... The update command doesn't work with this update. If country_id value is not null, it works... I precise that country_id is nullable in the DB. Thanks for any help. Best regards. Arthur

        S Offline
        S Offline
        shambho
        wrote on last edited by
        #3

        I dont know whether my suggestion is right. first check the entries are null or not. If null update with ''. ie blank. does this answer the question. sreejiths answer is a good way but working with insert,delete and update query in data adapter is not that easy.

        (Behind the truth)

        Anandah

        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