Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Navigating Table and related data tables
Message
De
06/07/2007 11:05:41
David Shedd
Memphis Police Department
Memphis, Tennessie, États-Unis
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Titre:
Navigating Table and related data tables
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01238218
Message ID:
01238218
Vues:
51
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform