Hi,
I'm new to programming vb.net. And i wont to try to save changes that i have made in a datagridview to my database.
Only, it it is not working. No changes are saved to the database. However the datagridview is filled with the results of my query.
My source looks like this:
Imports System
Imports System.Data
Public Class Form1
Dim ConDBF As OleDb.OleDbConnection
Dim ConCMD As OleDb.OleDbCommand
Dim DataAdap As OleDb.OleDbDataAdapter
Dim myDs As New DataSet()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ConStr As String
ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\TST_MAP\ITEST3\;Extended Properties=dBASE IV;User ID=Admin;Password="
ConDBF = New OleDb.OleDbConnection(ConStr)
ConCMD = New OleDb.OleDbCommand("SELECT * FROM Leerling WHERE NAAM Like '%ormans%' and VOORNAAM like '%rl%' ", ConDBF)
DataAdap = New OleDb.OleDbDataAdapter(ConCMD)
DataAdap.Fill(myDs, "Leerling")
BindingSource1.DataSource = myDs.Tables("Leerling")
DataGridView1.DataSource = BindingSource1
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DataAdap.Update(myDs, "Leerling")
End Sub
End Class
What do i have to do to save changes made in my datagridview to my database?
Thanks in advance!
Carlo
I'm new to programming vb.net. And i wont to try to save changes that i have made in a datagridview to my database.
Only, it it is not working. No changes are saved to the database. However the datagridview is filled with the results of my query.
My source looks like this:
Imports System
Imports System.Data
Public Class Form1
Dim ConDBF As OleDb.OleDbConnection
Dim ConCMD As OleDb.OleDbCommand
Dim DataAdap As OleDb.OleDbDataAdapter
Dim myDs As New DataSet()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ConStr As String
ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\TST_MAP\ITEST3\;Extended Properties=dBASE IV;User ID=Admin;Password="
ConDBF = New OleDb.OleDbConnection(ConStr)
ConCMD = New OleDb.OleDbCommand("SELECT * FROM Leerling WHERE NAAM Like '%ormans%' and VOORNAAM like '%rl%' ", ConDBF)
DataAdap = New OleDb.OleDbDataAdapter(ConCMD)
DataAdap.Fill(myDs, "Leerling")
BindingSource1.DataSource = myDs.Tables("Leerling")
DataGridView1.DataSource = BindingSource1
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DataAdap.Update(myDs, "Leerling")
End Sub
End Class
What do i have to do to save changes made in my datagridview to my database?
Thanks in advance!
Carlo