Hi guys,
After getting dataset's datatable by using wizard ,we can update those tables rows or table by calling that table's adapter. Like blow:
But think we have a manual table , now we want to update,insert or delete data manually.. but only by those above simple commands ... so should I try create dataAdapter for that Table.
Below there is an example for creating commands for select,insert,update,delete but those doesn't work as above should put someting more in it.
After getting dataset's datatable by using wizard ,we can update those tables rows or table by calling that table's adapter. Like blow:
VB.NET:
Me.Validate()
Me.DepartmentBindingSource.EndEdit()
Me.DesignationBindingSource.EndEdit()
Me.TableAdapter.Update(Me.DataSet1.table)
But think we have a manual table , now we want to update,insert or delete data manually.. but only by those above simple commands ... so should I try create dataAdapter for that Table.
Below there is an example for creating commands for select,insert,update,delete but those doesn't work as above should put someting more in it.
VB.NET:
Dim adapter As SqlDataAdapter = New SqlDataAdapter
' Create the commands.
adapter.SelectCommand = New SqlCommand( _
"SELECT CustomerID, CompanyName FROM CUSTOMERS", connection)
adapter.InsertCommand = New SqlCommand( _
"INSERT INTO Customers (CustomerID, CompanyName) " & _
"VALUES (@CustomerID, @CompanyName)", connection)
adapter.UpdateCommand = New SqlCommand( _
"UPDATE Customers SET CustomerID = @CustomerID, CompanyName = " & _
"@CompanyName WHERE CustomerID = @oldCustomerID", connection)
adapter.DeleteCommand = New SqlCommand( _
"DELETE FROM Customers WHERE CustomerID = @CustomerID", connection)