N
Nathalie Goffa
Hi everyone
It seems that i have a strange problem. Everytime i wan to update my
datasource i get the error "Concurrency update error: affected 0 records"
No one is using the database, except me. i have visited www.dotnet247.com
which list possible solutions, but none of these problems specificly address
my problem. When i design the database and the datagrid in design mode via
the wizard, all works fine, IF i uncheck "optimistic concurrency" in the
dataadapter wizard. Then i can update and do whatever i want. If i dont
uncheck this option then i get the above error.
Now when i try this in code, i can update if i only use the primary key in
my select statement( eg "SELECT productname from products")
When i try to include more fields than just the primary key, i get once
again the above error. Anyone a solution for this problem?
the database has one primary key (no autoincrement) and some text fields and
numberfields
Please help me! Im getting desperate on this...
Kind Regards
Rob
Dim connectionstring As String
Dim conn As New OleDbConnection()
Dim da As New OleDbDataAdapter("SELECT Productname,Extra,Lowest_Price from
Products order by ProductName", conn)
Dim ds As New DataSet()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
connectionstring = New String("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & GetSetting("Manager", "Options", "DatabasePath"))
conn.ConnectionString = connectionstring
conn.Open()
Me.WindowState = FormWindowState.Maximized
da.Fill(ds)
dg.DataSource = ds.Tables(0)
End Sub
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Resize
dg.Width = Me.Width - 100
dg.Height = Me.Height - 200
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
Dim bu As New OleDbCommandBuilder(da)
If ds.HasChanges Then
da.Update(ds)
End If
End Sub
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
conn.Close()
End Sub
End Class
It seems that i have a strange problem. Everytime i wan to update my
datasource i get the error "Concurrency update error: affected 0 records"
No one is using the database, except me. i have visited www.dotnet247.com
which list possible solutions, but none of these problems specificly address
my problem. When i design the database and the datagrid in design mode via
the wizard, all works fine, IF i uncheck "optimistic concurrency" in the
dataadapter wizard. Then i can update and do whatever i want. If i dont
uncheck this option then i get the above error.
Now when i try this in code, i can update if i only use the primary key in
my select statement( eg "SELECT productname from products")
When i try to include more fields than just the primary key, i get once
again the above error. Anyone a solution for this problem?
the database has one primary key (no autoincrement) and some text fields and
numberfields
Please help me! Im getting desperate on this...
Kind Regards
Rob
Dim connectionstring As String
Dim conn As New OleDbConnection()
Dim da As New OleDbDataAdapter("SELECT Productname,Extra,Lowest_Price from
Products order by ProductName", conn)
Dim ds As New DataSet()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
connectionstring = New String("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & GetSetting("Manager", "Options", "DatabasePath"))
conn.ConnectionString = connectionstring
conn.Open()
Me.WindowState = FormWindowState.Maximized
da.Fill(ds)
dg.DataSource = ds.Tables(0)
End Sub
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Resize
dg.Width = Me.Width - 100
dg.Height = Me.Height - 200
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
Dim bu As New OleDbCommandBuilder(da)
If ds.HasChanges Then
da.Update(ds)
End If
End Sub
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
conn.Close()
End Sub
End Class