Ahmad,
Well, your code looks ok from what I can see. Creating the DataAdapter as you did *should* set the myDA.SelectCommand to be your SELECT statement, but maybe there's a quirk somewhere and it's not setting it as it should (that would cause the CommandBuilder to not create it's Update command perhaps). I'm guessing ... as I said, it *looks* ok, but try this on for size (just to humor me <g>)
Dim mySql = "SELECT * FROM AN_Bank"
Dim myDA As New SqlDataAdapter()
myDA.SelectCommand = New SqlCommand(mySql, myConn.oConnection)
~~Bonnie
>Hi Bonnie,
>Yes I am using CommandBuilder, below is my related code in brief:
>
>' Initiolize ....
> Dim mySql = "SELECT * FROM AN_Bank"
> Dim myDA As New SqlDataAdapter(mySql, myConn.oConnection)
> Dim myCB As New SqlCommandBuilder(myDA)
>
> Dim myDS As New DataSet()
> Dim myDR As DataRow
>
>Private Sub frm_Bank_Load
> myDA.UpdateCommand = myCB.GetUpdateCommand
> myDA.Fill(myDS, "Bank")
>
> ' Fill the DataRow
> myDR = myDS.Tables("Bank").Rows(0)
>
> Call DataBinding()
>End Sub
>
>Private Sub DataBinding()
> Me.cbSelect.DataSource = myDS.Tables("bank").DefaultView
> Me.cbSelect.DisplayMember = "BankName_e"
>
> Me.txtBankName_e.DataBindings.Add("Text", myDS.Tables("Bank").DefaultView, "BankName_e")
> Me.txtBankName_a.DataBindings.Add("Text", myDS.Tables("Bank").DefaultView, "BankName_a")
>End Sub
>
>Private Sub btnSave_Click
> myDR("bankname_a") = "First Bank" ' This as test
> myDA.Update(myDS, "Bank")
> myDS.AcceptChanges()
>End Sub
>
>Thanks again
>
>
>
>>Well, you're probably missing a few steps somewhere. Did you use the CommandBuilder to set up your Insert/Update/Delete commands? Why don't you post the code you have for setting up the DataAdapter, etc. and maybe we can see what you're missing.
>>
>>~~Bonnie
>>
>>>Hi All,
>>>
>>>Any boady know what is rong in this simble code, my DataRow and DataSet is update, but Database is not updating.
>>>*** Note: I am using Sql - MSDE
>>>
>>>myDR("bankname_a") = "US First Bank"
>>>myDA.Update(myDS, "Bank")
>>>myDS.AcceptChanges()
>>>
>>>Thanks in advance