skyyakal Posted February 28, 2004 Posted February 28, 2004 Hello everybody, I'm killing myself with the following problem. I have a DataGrid and two buttons below. The first button1 executes the following code: Dim Counter As Integer Dim MyTable As DataTable = Me.Sim_DataSet.Tables("SimVariablesValues") For Counter = Convert.ToInt32(VVfrom_txtbox.Text) To Convert.ToInt32(VVto_txtbox.Text) Step Convert.ToInt32(VVStep_txtbox.Text) Dim NewEntry As DataRow = MyTable.NewRow NewEntry(0) = Me.FormID NewEntry(1) = Counter NewEntry(2) = Counter MyTable.Rows.Add(NewEntry) Console.WriteLine("Counter:" & Counter) Next Me.Sim_DataSet.AcceptChanges() Sim_SqlDataAdapter.Update(Sim_DataSet.SimVariablesValues) the second button2 executes this one: Sim_SqlDataAdapter.Update(Sim_DataSet.SimVariablesValues) If I add values in the DataSheet per hand and press the button2 all values from DataGrid is transferred to Ms SQL Server. If I press the button1, DataGrid shows the new values, but the data is not transferred to Ms SQL Server. Do I do anything wrong with Sim_SqlDataAdapter.Update(Sim_DataSet.SimVariablesValues) ?!?!??!?! I would appreciate any help! Greetings, cygent Quote
skyyakal Posted February 28, 2004 Author Posted February 28, 2004 I found my error. I had to put AccepedChanges at the end :-) like that: Dim Counter As Integer Dim MyTable As DataTable = Me.Sim_DataSet.Tables("SimVariablesValues") For Counter = Convert.ToInt32(VVfrom_txtbox.Text) To Convert.ToInt32(VVto_txtbox.Text) Step Convert.ToInt32(VVStep_txtbox.Text) Dim NewEntry As DataRow = MyTable.NewRow NewEntry(0) = Me.FormID NewEntry(1) = Counter NewEntry(2) = Counter MyTable.Rows.Add(NewEntry) Console.WriteLine("Counter:" & Counter) Next Sim_SqlDataAdapter.Update(Sim_DataSet.SimVariablesValues) Me.Sim_DataSet.AcceptChanges() 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.