I have an ASP.NET user control page and codebehind page that have a code problem that is not displaying in the trace. The page loads fine without errors but does not pull the database information. Any help with the included code would be greatly appreciated.
Thank you,
Dan
--------------------------------------------------------
CodeBehind Page:
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HTMLControls
Imports System.Collections
Imports System.Data.SqlClient
Imports System.Text.RegularExpressions
Imports Microsoft.VisualBasic
Public Class TrucksCodeBehind
Inherits Page
Protected conLocal As String = "Server=Local;UID=Guest;PWD=Password;Database=SQLDB"
Protected cmdSelectTrucks As SqlCommand
Protected dtrTrucks As SqlDataReader
Protected cmdSelectTrucks As SqlCommand
Sub Page_Load()
Dim conLocal As SqlConnection
Dim cmdSelectTrucks As SqlCommand
Dim dtrTrucks As SqlDataReader
Dim urlID = Request.QueryString("ID")
conLocal = New SqlConnection( "Server=Local;UID=Guest;PWD=Password;Database=SQLDB" )
conLocal.Open()
cmdSelectTrucks = New SqlCommand( "SELECT Make, Model, Year, Color, Engine FROM Trucks WHERE UID = " &urlID, conLocal )
dtrTrucks = cmdSelectTrucks.ExecuteReader()
While dtrTrucks.Read
lblMake.text = dtrTrucks("Make")
lblModel.text = dtrTrucks("Model")
lblYear.text = dtrTrucks("Year")
lblColor.text = dtrTrucks("Color")
lblEngine.text = dtrTrucks("Engine")
End While
dtrTrucks.Close()
dtrTrucks = Nothing
conLocal.Close()
conLocal = Nothing
End Sub
End Class
----------------------------------------------------
User Control Page:
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="Trucks.ascx.vb"%>
<table cellpadding="0" cellspacing="0" border="0" bordercolor="#000000" align="center">
<TR>
<td class="Content"><asp:label id="lblMake" Runat="server">Make: </asp:label><% Response.Write("Make") %></td>
</TR>
<TR>
<td class="Content"><asp:label id="lblModel" Runat="server">Model: </asp:label><% Response.Write("Model") %></td>
</TR>
<TR>
<td class="Content"><asp:label id="lblYear" Runat="server">Year: </asp:label><% Response.Write("Year") %></td>
</TR>
<TR>
<td class="Content"><asp:label id="lblColor" Runat="server">Color: </asp:label><% Response.Write("Color") %></td>
</TR>
<TR>
<td class="Content"><asp:label id="lblEngine" Runat="server">Engine: </asp:label><% Response.Write("Engine") %></td>
</TR>
</table>
Thank you,
Dan
--------------------------------------------------------
CodeBehind Page:
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HTMLControls
Imports System.Collections
Imports System.Data.SqlClient
Imports System.Text.RegularExpressions
Imports Microsoft.VisualBasic
Public Class TrucksCodeBehind
Inherits Page
Protected conLocal As String = "Server=Local;UID=Guest;PWD=Password;Database=SQLDB"
Protected cmdSelectTrucks As SqlCommand
Protected dtrTrucks As SqlDataReader
Protected cmdSelectTrucks As SqlCommand
Sub Page_Load()
Dim conLocal As SqlConnection
Dim cmdSelectTrucks As SqlCommand
Dim dtrTrucks As SqlDataReader
Dim urlID = Request.QueryString("ID")
conLocal = New SqlConnection( "Server=Local;UID=Guest;PWD=Password;Database=SQLDB" )
conLocal.Open()
cmdSelectTrucks = New SqlCommand( "SELECT Make, Model, Year, Color, Engine FROM Trucks WHERE UID = " &urlID, conLocal )
dtrTrucks = cmdSelectTrucks.ExecuteReader()
While dtrTrucks.Read
lblMake.text = dtrTrucks("Make")
lblModel.text = dtrTrucks("Model")
lblYear.text = dtrTrucks("Year")
lblColor.text = dtrTrucks("Color")
lblEngine.text = dtrTrucks("Engine")
End While
dtrTrucks.Close()
dtrTrucks = Nothing
conLocal.Close()
conLocal = Nothing
End Sub
End Class
----------------------------------------------------
User Control Page:
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="Trucks.ascx.vb"%>
<table cellpadding="0" cellspacing="0" border="0" bordercolor="#000000" align="center">
<TR>
<td class="Content"><asp:label id="lblMake" Runat="server">Make: </asp:label><% Response.Write("Make") %></td>
</TR>
<TR>
<td class="Content"><asp:label id="lblModel" Runat="server">Model: </asp:label><% Response.Write("Model") %></td>
</TR>
<TR>
<td class="Content"><asp:label id="lblYear" Runat="server">Year: </asp:label><% Response.Write("Year") %></td>
</TR>
<TR>
<td class="Content"><asp:label id="lblColor" Runat="server">Color: </asp:label><% Response.Write("Color") %></td>
</TR>
<TR>
<td class="Content"><asp:label id="lblEngine" Runat="server">Engine: </asp:label><% Response.Write("Engine") %></td>
</TR>
</table>