
dataset problems - cant update sql after editing dataset
Donald,
I don't know if this will help, but I ran into a
concurrency message updating an Access database.
What I discovered, is that whe I looked at the
oledbadapter (you would use the sql adapter) properties.
I went to the update command and expanded it. Clicked on
command text and clicked the "..." button. This displays
the update command in the querry builder. I discovered in
the Where part of the sql statement was a number of
conditions that were NOT the unique data key. I removed
all of these EXCEPt thew key (you can edit the select
statement or click off the icons that look like wine
glasses at the top window that list the fields).
Concuurency problem went away. I suggest you comment off
the refresh (I believe this is removing your changes which
is why you don't see anything updating) and try "fixing"
the update statement as described above. I would note
iwhat it was 1st so you can put it back if this makes it
worse. ;)
Good luck,
Peter
Quote:
>-----Original Message-----
>Heres the problem 3 buttons on the form do simple steps.
b1 loads a
>dataset called dataset21.
>B2. processes field that currently has first and last
name with comman
>seperator. and puts first
>and last name in its own field.
>B3. updates the sql database.
>If i use B1 to fill a datagrid on the form. Then change
any field then
>use the update button. (Button3) IT works as it should
and the sql
>database is updated.
>If i use B1 to fill and then B2 to run the process and
then B3 to
>update. The datagrid shows that the process changed the
dataset
>correctly, but when the update is performed, nothing
happens to the
>sql database.
>Before the line was put in to refresh the datagrid before
updating,
>an error would appear regarding. concurrency violations,
which i took
>to mean that i was trying to update something that the
adapter was
>trying to update. But im not sure about that. Adding the
refresh cured
>that, but the sql database is not ever updated when the
process runs.
>Private Sub Button1_Click(ByVal...
> DataSet21.Clear()
> OleDbDataAdapter1.Fill(DataSet21)
>End Sub
>Private Sub Button2_Click(ByVal...
> Dim x, y, hold1 As Integer
> Dim mydatarow As DataRow
> Dim check1, fname, lname, name1 As String
> Cursor.Current = Cursors.WaitCursor
> For Each mydatarow In Me.DataSet21.Tables
("Data_Employees").Rows
Quote:
> 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
> DataSet21.AcceptChanges()
> DataGrid1.Refresh()
>End Sub
>Private Sub Button3_Click(ByVal....
> OleDbDataAdapter1.Update(DataSet21)
> MessageBox.Show("Database updated!")
>End Sub
>What am i doing wrong. How do i get the database to
update after
>running a process on the dataset and changed datarows.
>Thanks in advance.
>.