|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Concurrency Violationfar everything has been working just swell. I have a menu selection in my main form that when clicked launches a "customer data" form that folks fill personal information into and the textboxes are bound to a certain number of fields with my "Budget" table. The code that launches the new window from my main form is: Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem6.Click Dim frmCustomerData As New CustomerData frmCustomerData.ShowDialog() End Sub Here's the code for the window that is launched: Private Sub CustomerData_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim AppBase As String ' Let's set the location of the Access db to the directory ' where the executable file resides AppBase = AppDomain.CurrentDomain.BaseDirectory & "data.mdb" ' Update our connection string Me.OleDbConnection1.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _ "ocking Mode=1;Data Source=" & AppBase & ";Jet OLEDB:Engine Type=5;Provider=""Mic" & _ "rosoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist sec" & _ "urity info=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:Encrypt Dat" & _ "abase=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale o" & _ "n Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet" & _ " OLEDB:Global Bulk Transactions=1" DataSet21.Clear() OleDbDataAdapter1.Fill(DataSet21) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim cm As CurrencyManager cm = DirectCast(BindingContext(DataSet21, "Budget Items"), CurrencyManager) cm.EndCurrentEdit() Try OleDbDataAdapter1.Update(DataSet21, "Budget Items") Me.Close() Catch ex As Exception MsgBox(ex.ToString) Me.Close() End Try End Sub End Class ------------------------------------------- Here's the problem: When I make any changes to the customer data window, the information DOES get recorded to the db. However, if I go back to my main form WHICH ALSO USES THE BUDGET TABLE I get a Concurrency violation when this line gets hit: OleDbDataAdapter1.Update(DsMyMonthlyIncome1, "Budget Items") The DsMyMonthlyIncome1 is a Data Set for the main form. My window form that takes care of customer data recording uses a different data set and dbadapter as well as oledbdataconnection. If I close my application AFTER making the updates regarding customer information from my secondary window, there's no problem entering and saving data in my main form, so something is wrong after the secondary window updates the budget table AND IS NOT LETTING GO of whatever so the main form can do its update. I've tried all sorts of close methods on the secondary window's dataadapter/connection/dataset and nothing seems to work. Sure am stumped... -Dan One thing that comes to mind: I'm only updating a handful of fields in
the "Budget Table" with my secondary data-gathering window. When this window closes and call the update function to make sure my bound textboxes sync with the "Budget Table", will it get p****d off because the handful of rows I updated recently have some sort of different time stamp???? So how does one properly work with the same table using two windows with non-overlapping bound textboxes? -Dan On Mar 29, 5:45 pm, "pooba53" <poob***@gmail.com> wrote: I fixed it. For whatever reason, if I add the following after"frmCustomerData.ShowDialog()", in the calling routine, life goes on: OleDbDataAdapter1.Fill(DsMyMonthlyIncome1) Must be something about "refreshing" the data set. I don't know... Hope this helps somebody ;-) <snip> > Dim frmCustomerData As New CustomerData <snip>> frmCustomerData.ShowDialog() > End Sub > > Here's the code for the window that is launched: > |
|||||||||||||||||||||||