I have populated a DataGridView
from the two tables.
In page load event I have this code:
Dim da As New SqlDataAdapter
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Using adapter As SqlDataAdapter = New SqlDataAdapter("select c.CompanyName,d.dtName,d.dtPhone,d.dtEmail from CompanyMaster_tbl c join DepartmentMaster_tbl d on c.Cid=d.cId", con.connect)
Dim dt As DataTable = New DataTable()
adapter.Fill(dt)
gv.DataSource = dt
End Using
End Sub
in update button click i given code like this:
da = New SqlDataAdapter
Dim dt1 As DataTable = DirectCast(gv.DataSource, DataTable)
da.Update(dt1)
gv.DataSource = dt1
but after editing anything in gridview,,i click the update button,,but i am getting error in this row da.Update(dt1)
Error:
Update requires a valid UpdateCommand when passed DataRow collection with modified rows.