how to data edit in datagrid view and update in database

  • Thread starter Thread starter muhammadanzar
  • Start date Start date
M

muhammadanzar

Guest
hi,

i retrieve data from database. after that change in datagridview in many rows, when button "Update" pressed can be update in database. my code is



Dim DBconn As New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=StudentData;Integrated Security=True")
If (DBconn.State = ConnectionState.Closed) Then DBconn.Open()
Dim SQLAdapter = New SqlDataAdapter("SELECT * FROM Students", DBconn) 'SqlCeDataAdapter
Dim SQLDataSet As New DataSet
Dim myTable = DataGridView1.DataSource
Dim cmdbuilder As New SqlCommandBuilder(SQLAdapter)
SQLAdapter.Update(myTable, "Students")
MsgBox("Updated!", MsgBoxStyle.OkOnly, "")

1538698.png


MUHAMMAD ANZAR E-mail : muhammadanzar@hotmail.com Mobile # :0092-3215096959

Continue reading...
 
Back
Top