Database Problems  
Author Message
Eswans2000





PostPosted: Visual Basic Express Edition, Database Problems Top

I have a database that I update in a project. I connected several forms to this database. (Please keep in mind that I am a novice at best)

I noticed that I can update the database in one form and then in the other and the forms only see their updates, not the updates from the other forms. Any ideas what I'm doing wrong

I published it really quick to see if it was just a debugging thing and it wasnt...I saw the same thing on the published version. Thanks

Eric Swanson



Visual Studio Express Editions13  
 
 
ahmedilyas





PostPosted: Visual Basic Express Edition, Database Problems Top

can you post some code



 
 
Eswans2000





PostPosted: Visual Basic Express Edition, Database Problems Top

This is the code i'm using for the first form. The names for things are fairly generic right now because i'm just trying to get it to work. There are a few test buttons in there.

Button 1 basically makes an addition to the database. Button 4 saves it and it does show up in the datagrid on this form. I did that only to see it work. What I really wanted to happen was you clicked Button 1 and a new form opens that you enter the information into and save it to the database that way as shown on button 6. This is the code for the first form:

Public Class Satellite_Databases

Private Sub Satellite_Databases_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'TODO: This line of code loads data into the 'Satellite_DatabaseDataSet.Satellite_Database' table. You can move, or remove it, as needed.

Me.Satellite_DatabaseTableAdapter.Fill(Me.Satellite_DatabaseDataSet.Satellite_Database)

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Me.SatelliteDatabaseBindingSource.AddNew()

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Me.SatelliteDatabaseBindingSource.RemoveCurrent()

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

Me.SatelliteDatabaseBindingSource.EndEdit()

Me.Satellite_DatabaseTableAdapter.Update(Me.Satellite_DatabaseDataSet.Satellite_Database)

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

Me.SatelliteDatabaseBindingSource.RemoveCurrent()

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

Me.Hide()

Add_Satellite.Show()

End Sub

End Class


 
 
Eswans2000





PostPosted: Visual Basic Express Edition, Database Problems Top

Unfortunately, I kept the names as button 1...etc etc on the second form which might make it hard for me to get across what I want.

This is the second form that opens up(Code):

Public Class Add_Satellite

Private Sub Add_Satellite_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'TODO: This line of code loads data into the 'Satellite_DatabaseDataSet.Satellite_Database' table. You can move, or remove it, as needed.

Me.Satellite_DatabaseTableAdapter.Fill(Me.Satellite_DatabaseDataSet.Satellite_Database)

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Me.Hide()

Satellite_Databases.Show()

Me.SatelliteDatabaseBindingSource.RemoveCurrent()

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Me.SatelliteDatabaseBindingSource.EndEdit()

Me.Satellite_DatabaseTableAdapter.Update(Me.Satellite_DatabaseDataSet.Satellite_Database)

Me.Hide()

Satellite_Databases.Show()

Satellite_Databases.Refresh()

End Sub

End Class


 
 
Eswans2000





PostPosted: Visual Basic Express Edition, Database Problems Top

Ok, I found the fix for it though I dont completely understand it.

I stopped using *.hide() and used *.close() and now it works.

So, problem solved though I would love an explanation if anyone has it. Thanks

Eric