N
nmrpa91290
I have a vb 2005 program that I am writing. It is just a form with a
datagridview, textbox, and import command button. The code looks like
this:
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
'TestDbDataSet.TestTable' table. You can move, or remove it, as
needed.
Me.TestTableTableAdapter.Fill(Me.TestDbDataSet.TestTable)
End Sub
Private Sub cmdImport_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles cmdImport.Click
Dim col1, col2 As String
Dim NewRow As DataRow
NewRow = TestDbDataSet.Tables(0).NewRow
col1 = txtImport.Text
col2 = txtImport.Text
NewRow.Item("Data1") = col1
NewRow.Item("Data2") = col2
Try
TestDbDataSet.Tables(0).Rows.Add(NewRow)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub TestTableBindingNavigatorSaveItem_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
TestTableBindingNavigatorSaveItem.Click
Me.Validate()
Me.TestTableBindingSource.EndEdit()
Me.TestTableTableAdapter.Update(Me.TestDbDataSet.TestTable)
End Sub
--------------------------------------------------------------------------------------------------------------------------------
It successfully adds rows to the datagridview control on the form.
However, it does not actually save the data into the access database
that I have created. When I open the database in Access after saving
the data in my application it is not present in the table. Nor is it
present when I close the application and then open it again. Can you
actually save the data entered in a vb 2005 independent windows
application to a previously created database? Or, does it just update
the control on the form making it look like it updated the database
table? Help would be greatly appreciated!
datagridview, textbox, and import command button. The code looks like
this:
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
'TestDbDataSet.TestTable' table. You can move, or remove it, as
needed.
Me.TestTableTableAdapter.Fill(Me.TestDbDataSet.TestTable)
End Sub
Private Sub cmdImport_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles cmdImport.Click
Dim col1, col2 As String
Dim NewRow As DataRow
NewRow = TestDbDataSet.Tables(0).NewRow
col1 = txtImport.Text
col2 = txtImport.Text
NewRow.Item("Data1") = col1
NewRow.Item("Data2") = col2
Try
TestDbDataSet.Tables(0).Rows.Add(NewRow)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub TestTableBindingNavigatorSaveItem_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
TestTableBindingNavigatorSaveItem.Click
Me.Validate()
Me.TestTableBindingSource.EndEdit()
Me.TestTableTableAdapter.Update(Me.TestDbDataSet.TestTable)
End Sub
--------------------------------------------------------------------------------------------------------------------------------
It successfully adds rows to the datagridview control on the form.
However, it does not actually save the data into the access database
that I have created. When I open the database in Access after saving
the data in my application it is not present in the table. Nor is it
present when I close the application and then open it again. Can you
actually save the data entered in a vb 2005 independent windows
application to a previously created database? Or, does it just update
the control on the form making it look like it updated the database
table? Help would be greatly appreciated!