Update problems!!

sizer

Well-known member
Joined
Mar 6, 2003
Messages
123
Location
Croatia
Can anyone help me!!!

Here is the code and explanation:

When i press button1 (which is Update) my DB should be Updated but that doesnt work.Why?Why?
dsn=acc is ODBC connection to ACCESS DB

Code:
Dim con As New ODBC.OdbcConnection("dsn=acc")
    Dim command As New ODBC.OdbcCommand("SELECT * FROM SERVIS", con)
    Dim adp As New ODBC.OdbcDataAdapter(command)
    Dim ds As New DataSet("SERVIS")
    Dim cmdBuilder As New ODBC.OdbcCommandBuilder(adp)

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        adp.Fill(ds, "SERVIS")

        TextBox1.DataBindings.Add("Text", ds, "SERVIS.Rbr")
        DataGrid1.DataMember = "SERVIS"
        DataGrid1.DataSource = ds
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        adp.Update(ds, "SERVIS")
        ds.AcceptChanges()
    End Sub
 
Last edited by a moderator:
Before updating you need to change the DataAdapters command to an Update statement (not a Select statement). Then use the Update method of the DataAdapter to actually update.
 
When I do same thing with DAtaGrid it works fine!!
Ive declared Command Builder to do UPDATE,INSERT,DELETE command instead ME!!

If Im wrong can you post some example!!

Thanks
 
Back
Top