Dataset changes updates grid , How to update SQL table 
Author Message
 Dataset changes updates grid , How to update SQL table

Ive got what should be a simple dataset update problem.  Ive got the
dataset edited and my changes show up in the datagrid after
datagrid1.refresh, but how do i get the changes from the dataset to be
applied to the SQL table. Ive tried updating the adapter and various
other things. What am i missing?

Dim x, hold1 As Integer
Dim mydatarow As DataRow
Dim check1, fname, lname, name1 As String
Dim Employees1 As DataSet = Employees1  

Cursor.Current = Cursors.WaitCursor
Me.FillDataSet(Employees1)
For Each mydatarow In Me.Employees1.Tables("Data_Employees").Rows
        name1 = (mydatarow("holdname").ToString())
        hold1 = Len(name1)
        For x = 1 To hold1
                check1 = name1.Substring(x - 1, 1)
                If check1 = "," Then
                        lname = name1.Substring(0, x - 1)
                        fname = name1.Substring(x + 1, (hold1 - x) - 1)
                        mydatarow.BeginEdit()
                        mydatarow.Item("Firstname") = fname
                        mydatarow.Item("Lastname") = lname
                        mydatarow.AcceptChanges()
                        Exit For
                End If
        Next
Next
Me.DataGrid1.Refresh()
Me.OleDbDataAdapter1.Update(Me.Employees1, "Data_Employees")  'IS THIS
CORRECT?
Cursor.Current = Cursors.Default

The bound datagrid shows the proper changes as they should be in the
sql table when finished.  How do i make the table update????
Thanks in advance
Don.S



Tue, 26 Jul 2005 01:03:46 GMT  
 Dataset changes updates grid , How to update SQL table
I think the problem is that you're updating the local Employees1 dataset,
but then you call update on Me.Employees1, a different dataset.
I would try not to use the same variable names, because this causes
confusion.
What does Me.FillDataSet do?
What is DataGrid1 bound to?

Lorenzo Minore,
VB .Net development

--
This posting is provided "AS IS" with no warranties, and confers no rights.

Quote:
> Ive got what should be a simple dataset update problem.  Ive got the
> dataset edited and my changes show up in the datagrid after
> datagrid1.refresh, but how do i get the changes from the dataset to be
> applied to the SQL table. Ive tried updating the adapter and various
> other things. What am i missing?

> Dim x, hold1 As Integer
> Dim mydatarow As DataRow
> Dim check1, fname, lname, name1 As String
> Dim Employees1 As DataSet = Employees1

> Cursor.Current = Cursors.WaitCursor
> Me.FillDataSet(Employees1)
> For Each mydatarow In Me.Employees1.Tables("Data_Employees").Rows
> name1 = (mydatarow("holdname").ToString())
> hold1 = Len(name1)
> For x = 1 To hold1
> check1 = name1.Substring(x - 1, 1)
> If check1 = "," Then
> lname = name1.Substring(0, x - 1)
> fname = name1.Substring(x + 1, (hold1 - x) - 1)
> mydatarow.BeginEdit()
> mydatarow.Item("Firstname") = fname
> mydatarow.Item("Lastname") = lname
> mydatarow.AcceptChanges()
> Exit For
> End If
> Next
> Next
> Me.DataGrid1.Refresh()
> Me.OleDbDataAdapter1.Update(Me.Employees1, "Data_Employees")  'IS THIS
> CORRECT?
> Cursor.Current = Cursors.Default

> The bound datagrid shows the proper changes as they should be in the
> sql table when finished.  How do i make the table update????
> Thanks in advance
> Don.S



Tue, 26 Jul 2005 05:27:13 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Updating a SQL-Table form modified Dataset.

2. dataset problems - cant update sql after editing dataset

3. Grid update sqldataadapter dataset UpdateCommand Object Reference

4. Update Mulitiple tables in a dataset.

5. doing updating from grid to sql server with stored procedure sql 2000

6. CR.NET:Fields not updated when dataset changes

7. Update Data Gird on change in DataSet

8. updating a dataset to the SQL Database

9. Update SQL table from data in another table

10. Updating Tables with SQL in VB6 using vfoxpro tables

11. Using--After Update-- to update field in table.

12. Help: updating text file-Updating Data in a linked table not supported by this ISAM

 

 
Powered by phpBB® Forum Software