EricDotNet Posted March 25, 2004 Posted March 25, 2004 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) Quote
EricDotNet Posted March 25, 2004 Author Posted March 25, 2004 No Error prompt... I can't update the changed data into database. Quote
Illusion Posted March 31, 2004 Posted March 31, 2004 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 ... :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.