hi I am creating a very simple project in vb 2008 with 2 forms(form1,form2)
form1 is in detail view and form2 is in datagrid view, both are bound to the same database LAF.mdb and the table name is Table1. all it does is save new record to the database from form1 and also when the record is selected from form2 in datagrid view it pops up with the specific record, which i need to then update back to the database.I have used wizard to make the connection to database for both forms. Now I can save new record(in form1), populate the datagrid view with all the recods or by filtering and also can open selected record with all details correctly into form1 from form2.then when i try to update the record it only updates into the datagridview but doesnt update in the database.and also if i click onto show all records or refresh datagridview it resets the old record into the datagridview.
On form1 i have 4 buttons and also binding navigator and lots of textboxes, checkboxes,combo and datetimepickers.
add new(button 4)
save(button2)
update(does the same thing as save button3)
search(opens form1 button1)
form2 i have 4 buttons and a datagrid view which was dragged from datasource window
button2 show all
button 4 clear dgv
button3 to show the record on new form
button1 for filtering
if you need any more details pls ask me. I desperately need it to be running asap.Any help will be greatly appreciated. thanks in advance.
form1 is in detail view and form2 is in datagrid view, both are bound to the same database LAF.mdb and the table name is Table1. all it does is save new record to the database from form1 and also when the record is selected from form2 in datagrid view it pops up with the specific record, which i need to then update back to the database.I have used wizard to make the connection to database for both forms. Now I can save new record(in form1), populate the datagrid view with all the recods or by filtering and also can open selected record with all details correctly into form1 from form2.then when i try to update the record it only updates into the datagridview but doesnt update in the database.and also if i click onto show all records or refresh datagridview it resets the old record into the datagridview.
On form1 i have 4 buttons and also binding navigator and lots of textboxes, checkboxes,combo and datetimepickers.
add new(button 4)
save(button2)
update(does the same thing as save button3)
search(opens form1 button1)
form2 i have 4 buttons and a datagrid view which was dragged from datasource window
button2 show all
button 4 clear dgv
button3 to show the record on new form
button1 for filtering
VB.NET:
FORM1
Public Class Form1
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form2.Show()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Validate()
Me.Table1BindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.LAFDataSet)
End Sub
Public Property DataSource() As Object
Get
Return Me.Table1BindingSource.DataSource
End Get
Set(ByVal value As Object)
Me.Table1BindingSource.DataSource = value
End Set
End Property
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Validate()
Me.Table1BindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.LAFDataSet)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.Table1BindingSource.AddNew()
End Sub
Private Sub Table1BindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Validate()
Me.Table1BindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.LAFDataSet)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'LAFDataSet.Table1' table. You can move, or remove it, as needed.
End Sub
End Class
FORM2
Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'LAFDataSet.Table1' table. You can move, or remove it, as needed.
Me.Table1BindingSource.DataSource = LAFDataSet.Table1
Me.Table1DataGridView.DataSource = Me.Table1BindingSource
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
MsgBox("Reference no required !!!!")
Else
Me.Table1BindingSource.Filter = "[ID]='" & TextBox1.Text & "'"
Me.Table1TableAdapter.Fill(Me.LAFDataSet.Table1)
Table1DataGridView.DataSource = Table1BindingSource
Table1DataGridView.Refresh()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Table1DataGridView.DataSource = LAFDataSet.Table1
Table1DataGridView.Refresh()
Me.Table1TableAdapter.Fill(Me.LAFDataSet.Table1)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Table1DataGridView.DataSource = Nothing
Table1DataGridView.Refresh()
Me.Refresh()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End Sub
Private Sub Table1DataGridView_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles Table1DataGridView.CellDoubleClick
Dim f1 As New Form1
f1.Table1BindingSource.DataSource = Me.Table1BindingSource(e.RowIndex)
f1.ShowDialog()
End Sub
End Class
if you need any more details pls ask me. I desperately need it to be running asap.Any help will be greatly appreciated. thanks in advance.