thebatfink
Well-known member
- Joined
- Mar 29, 2012
- Messages
- 47
- Programming Experience
- Beginner
Hi, I am retrieving records from an external data source, displaying them in a datagridview and making changes to the data (manually) in the gridview. I have a button on the form containing the datagridview which triggers a sub I am expecting to commit the changes back to the external source, but it isn't making those changes. If anyone in the know could nudge me in the correct direction with this it would be much appreciated!
Here is my data retrieval and display code (in form1 - works ok):
Here is my commit code (in form2 - doesnt seem to work, but doesnt error either):
Variables (in module1):
Thanks!
Here is my data retrieval and display code (in form1 - works ok):
VB.NET:
Public Class Form1
Dim dbSource As String
~
Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles Button5.Click
Dim dbConnection As New SQLite.SQLiteConnection()
Dim dbCommand As SQLite.SQLiteCommand
dbConnection.ConnectionString = "Data Source= " & dbSource & ";"
dbConnection.Open()
dbCommand = dbConnection.CreateCommand
dbCommand.CommandText = "SELECT id,title,certification FROM movie_info WHERE certification='12'"
'retrieve records from the database and fill the datatable
Dim myAdapter As New SQLite.SQLiteDataAdapter(dbCommand)
Dim myBuilder As New SQLite.SQLiteCommandBuilder(myAdapter)
myAdapter.Fill(myTable)
'display the datatable contents in a gridview
Form2.DataGridView1.DataSource = myTable
'show the form containing the gridview
Form2.ShowDialog()
End Sub
End Class
Here is my commit code (in form2 - doesnt seem to work, but doesnt error either):
VB.NET:
Public Class Form2
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'commit changes in the datatable to the database
myTable.AcceptChanges()
myAdapter.Update(myTable)
End Sub
End Class
Variables (in module1):
VB.NET:
Module Module1
Public myTable As New DataTable()
Public myAdapter As New SQLite.SQLiteDataAdapter()
Public myBuilder As New SQLite.SQLiteCommandBuilder()
End Module
Thanks!