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?
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?