General information
Title:
Navigating Table and related data tables
Environment versions
Network:
Windows 2003 Server
I am a New VB.Net programmer, I have a windows form with a tab contol, I am connectiong to a SQL data base and using 5 tables. I am trying to add, save, search (Next record, Last, prevoius, First) The built in BindingNavigator binds only to one Table. I have created a pulic class to set up a dataset for the entire form
'Add Tables to DS(Data Set)
gngstrTableAdapter.Fill(GangDS, "Gangsters")
gngTableAdapter.Fill(GangDS, "Gangs")
critTableAdapter.Fill(GangDS, "GangCriteria")
vehTableAdapter.Fill(GangDS, "GangVehicles")
this is the code I wrote to Search,
Dim strInfo As String = ""
Dim DrGangsters As DataRow = Nothing
Dim DsGangs As DataRow() = Nothing
' Get the specified record ID from the Textbox
Dim LName As String = Me.TxtSLName.Text.ToString()
Dim FName As String = Me.TxtSFName.Text.ToString()
Dim DOB As String = Me.TxtDob.Text.ToString()
Dim Date_Entered As String = Me.DpDate_Entered.Text.ToString()
' Now based on ID, get the correct row in the table
DrGangsters = GangDS.Tables("Gangsters").Rows(LName + FName + DOB + Date_Entered)
strInfo &= "ID" & DrGangsters("GLinkKey").ToString() & "" & Chr(10) & ""
' Navigate from GangCriteria table to GangVehicle table
DsGangs = DrGangsters.GetChildRows(GangDS.Relations("CriteriaVehicle"))
' Navigate from Gangs table to GangCriteria table
DsGangs = DrGangsters.GetChildRows(GangDS.Relations("GangsGangCriteria"))
' Get the record
For Each r As DataRow In DsGangs
strInfo &= "Gangs: " & r("GLinkKey").ToString() & "" & Chr(10) & ""
Next
' Now navigate from GangCriteria to Gangsters
Dim DrsGngstr As DataRow() = DsGangs(0).GetParentRows(GangDS.Relations("GangstersGang"))
'Get Info
For Each r As DataRow In DrsGngstr
strInfo &= "Last Name: " & r("lname").ToString() & "" & Chr(10) & ""
strInfo &= "First Name: " & r("fname").ToString() & "" & Chr(10) & ""
strInfo &= "Date of Birth: " & r("dob").ToString() & "" & Chr(10) & ""
strInfo &= "Gang: " & r("gang").ToString() & "" & Chr(10) & ""
Next
MessageBox.Show(strInfo, "Info based on ID")
This returnes an error "can not convert to interger"
How would I then add, save and navigate ?
Any help at all is appreciated
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only