P
pooba53
My VB .NET 2003 application communicates with an Access database. So
far 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 OLEDBatabase 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
OLEDBon'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
far 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 OLEDBatabase 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
OLEDBon'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