Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help with DataReader.

Status
Not open for further replies.

DanOoo

Programmer
Feb 26, 2005
15
US
I have a code problem that is not displaying in the debug or trace. The page loads fine without errors but does not pull the database information. Any help with the code below would be greatly appreciated.
Thank you,
DanOoo

--------------------------------------------------------

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

----------------------------------------------------

<%@ 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: &nbsp;</asp:label><% Response.Write("Make") %></td>
</TR>
<TR>
<td class="Content"><asp:label id="lblModel" Runat="server">Model: &nbsp;</asp:label><% Response.Write("Model") %></td>
</TR>
<TR>
<td class="Content"><asp:label id="lblYear" Runat="server">Year: &nbsp;</asp:label><% Response.Write("Year") %></td>
</TR>
<TR>
<td class="Content"><asp:label id="lblColor" Runat="server">Color: &nbsp;</asp:label><% Response.Write("Color") %></td>
</TR>
<TR>
<td class="Content"><asp:label id="lblEngine" Runat="server">Engine: &nbsp;</asp:label><% Response.Write("Engine") %></td>
</TR>
</table>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top