I have a question which might sound silly but I'm new to datagrids and data binding in vs 2005.
I have successfully created a datagridview which gets its data from a datatable / table adapter. The sql being executed in the fill method looks like this:
The code to display the data in the grid looks like this:
I only want the user to be able to change the territory name. They must specify a name that already exists in the Territory table. The contacts table only has a FK to the Territory Table. How would i write the sql update method?
The code that I've written so far in vb for the SAVE button looks like this:
Please and thanks.
I have successfully created a datagridview which gets its data from a datatable / table adapter. The sql being executed in the fill method looks like this:
SELECT Contact.FName, Contact.LName, Contact.StreetNum, Street.Name AS Street, City.Name AS City, Contact.PostalCode,
Contact.PhoneNumber, Contact.ApartmentNum, Contact.DoNotCall, Contact.TerritoryID, Territory.Name
FROM Contact INNER JOIN
City ON Contact.CityID = City.CityID INNER JOIN
Street ON Contact.StreetID = Street.StreetID INNER JOIN
Territory ON Contact.TerritoryID = Territory.TerritoryID
WHERE (Territory.Name = @TerrName)
Contact.PhoneNumber, Contact.ApartmentNum, Contact.DoNotCall, Contact.TerritoryID, Territory.Name
FROM Contact INNER JOIN
City ON Contact.CityID = City.CityID INNER JOIN
Street ON Contact.StreetID = Street.StreetID INNER JOIN
Territory ON Contact.TerritoryID = Territory.TerritoryID
WHERE (Territory.Name = @TerrName)
The code to display the data in the grid looks like this:
Me.LookUpTerritoryByNameTableAdapter.Fill(Me._territor_eDataSet.LookUpTerritoryByName, txtTerritoryName.Text)
I only want the user to be able to change the territory name. They must specify a name that already exists in the Territory table. The contacts table only has a FK to the Territory Table. How would i write the sql update method?
The code that I've written so far in vb for the SAVE button looks like this:
Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Save.Click
(Me._territor_eDataSet.LookUpTerritoryByName)
Dim table As DataTable
table = Me._territor_eDataSet.LookUpTerritoryByName.GetChanges
If (Not IsNothing(table)) Then
Me.LookUpTerritoryByNameTableAdapter.Update(table)
Me._territor_eDataSet.LookUpTerritoryByName.AcceptChanges()
End If
End Sub
(Me._territor_eDataSet.LookUpTerritoryByName)
Dim table As DataTable
table = Me._territor_eDataSet.LookUpTerritoryByName.GetChanges
If (Not IsNothing(table)) Then
Me.LookUpTerritoryByNameTableAdapter.Update(table)
Me._territor_eDataSet.LookUpTerritoryByName.AcceptChanges()
End If
End Sub
Please and thanks.