I am fairly new to databases and Linq to SQL, but I have been able to find solutions to most of my problems through the internet and various books that i own. Yet I am having a problem when populating my datagrid, and I am unable to find anyone with the same problem or any work around for the problem.
Here is my code for my query and population of my textboxes and datagrid:
Dim dbVehSearch As New VehicleDataClassesDataContext
Dim makeSearch = (From v In dbVehSearch.Vehicles Where v.VehicleId = CStr(txtVehID.Text)).SingleOrDefault()
Dim bolExists As Boolean = If(makeSearch Is Nothing, True, False)
If bolExists = False Then
'txtMake.Text = makeSearch.FirstOrDefault.ToString
txtMake.Text = makeSearch.Make
txtModel.Text = makeSearch.Model
txtModelYear.Text = makeSearch.ModelYear
txtEngine.Text = makeSearch.Engine
txtOilFilter.Text = makeSearch.OilFilter
txtQts.Text = makeSearch.QtsAmt
dgPastServices.ItemsSource = makeSearch.Services
Else
txtMake.Text = vbNullString
txtModel.Text = vbNullString
txtModelYear.Text = vbNullString
txtEngine.Text = vbNullString
txtOilFilter.Text = vbNullString
txtQts.Text = vbNullString
dgPastServices.ItemsSource = Nothing
End If
All works as I wish except for when the datagrid is populated I get two unwanted columns at the end with the names of two of my three tables in the database. I'm not sure why the table names are being inserted here or how to get rid of them. Here is a link to what the datagrid looks like.
datagrid with extra columns of table names
Any help would be greatly appreciated.
"Invoices" and "Vehicle" are the extra columns. Also in the Vehicle column is what looks like some code.