Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi, all

 

I confused that datagrid cannot update to db.

I create a dataset and fill in the datagrid component.

   Private Sub frmCountry1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       dim sSQL as string 
       dim da as new dataAdapter()
       dim ds as new dataSet()

       sSQL = "SELECT * FROM COUNTRY"

       da = New SqlDataAdapter(sSQL, sConnString)
       da.TableMappings.Add("Table", "TMP")
       da.Fill(ds)
       datagrid1.DataSource = ds.Tables("TMP")
   End Sub

 

When I modify the records in datagrid, I can't update to database...

How can I do it?

 

I have try this.... :confused: no effect .... :o

       ds.Tables("TMP").AcceptChanges()
       da.Update(ds)

Posted

remove the ds.Tables("TMP").AcceptChanges() line ...

that command is saying to the dataset that you have accepted all changes and there is nothing to update to the SQL .. which means you are shooting yourself in the foot.. take it out and it should either work or crash which means you are a little further then before ... :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...