Not the correct result

G

Guest

I am not getting the result that I am expecting in the last statement of the
following code:

Dim dsServer As New DataSet
Dim cmdServer As New SqlCommand
Dim sSelect As String = "SELECT tblServer.DNSName FROM tblServer WHERE
tblServer.ServerID = " & Integer.Parse(Request.QueryString("ID"))
cmdServer.CommandText = sSelect
cmdServer.Connection = SqlConnection1

Dim daServer As New SqlDataAdapter
daServer.SelectCommand = cmdServer
daServer.MissingSchemaAction = MissingSchemaAction.AddWithKey
daServer.Fill(dsServer)
Dim drServer As DataRow
Dim iCurrentRow As Integer
drServer = dsServer.Tables(0).Rows(iCurrentRow)
txtDNSName.Text = drServer("DNSName")

Dim daAppList As New SqlDataAdapter
Dim dsAppList As New DataSet
Dim cmdAppList As New SqlCommand
Dim sSelect2 As String = "SELECT tblApplication.ApplicationID,
tblApplication.Application, tblApplication.RedBookNumber " & _
"FROM tblServer INNER JOIN tblCrossRef ON tblServer.ServerID =
tblCrossRef.ServerID INNER JOIN tblApplication ON tblCrossRef.ApplicationID =
tblApplication.ApplicationID " & _
"WHERE tblServer.ServerID = " & Integer.Parse(Request.QueryString("ID"))
cmdAppList.CommandText = sSelect2
cmdAppList.Connection = SqlConnection1
daAppList.SelectCommand = cmdServer
daAppList.MissingSchemaAction = MissingSchemaAction.AddWithKey
daAppList.Fill(dsAppList)
dgAppList.DataSource = dsAppList
'dgAppList.DataMember = "ApplicationID"
'dgAppList.DataKeyField = "ApplicationID"
dgAppList.DataBind()

The datagrid is returning the results of the first select statement instead
of the second. Any insight into why this is happening?
 
G

Guest

Just a guess but I'd say that dsAppList now has 2 tables in it.
dsAppList.Tables(0) is the first result.
dsAppList.Tables(1) is the second.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,128
Latest member
ElwoodPhil
Top