Hi,
I have a DatagridView and I want to save changes to the datagridview to my SQL Server database.
I have the following code:
I would be very grateful if someone can help me, please.
Ijaz
I have a DatagridView and I want to save changes to the datagridview to my SQL Server database.
I have the following code:
Code:
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim path As String
path = ConfigurationManager.AppSettings("SQLDBPath")
Dim connectionString As String = path
Dim strSql As String = "SELECT * FROM dbo.b2020Survey"
Dim dtb As New DataTable
Using cnn As New SqlConnection(connectionString)
cnn.Open()
Using dad As New SqlDataAdapter(strSql, cnn)
dad.Fill(dtb)
End Using
cnn.Close()
End Using
DataGridView1.DataSource = dtb
dtb.AcceptChanges()
End Sub
Ijaz