HarleySkater
asked on
Sql Data Reader not displaying return Values
I am having trouble getting data returned from a Stored Procedure to display in a Repeater.
I know the Stored Procedure is working and I know it is returning data, I tested it with a label, its shown in the code snippet.
how do you get returned data to display in the repeater?
Thanks :D
I know the Stored Procedure is working and I know it is returning data, I tested it with a label, its shown in the code snippet.
how do you get returned data to display in the repeater?
Thanks :D
------ ASPX Code
<asp:Label ID="UserIdLabel" runat="server" Text=""></asp:Label>
<hr />
<asp:Repeater id="ListProfiles" runat="server" EnableViewState="False">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "UserId") %>
</ItemTemplate>
</asp:Repeater>
------ Behind VB Code
Using myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("AGConnectionString").ConnectionString)
Using myCommand As New SqlCommand("AGProfileSearchName", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
myConnection.Open()
myCommand.Parameters.AddWithValue("@SearchName", SearchName)
Dim dr As SqlDataReader = myCommand.ExecuteReader()
dr.Read()
UserIdLabel.Text = dr("UserId").ToString().Trim()
ListProfiles.DataSource = dr
ListProfiles.DataBind()
dr.Close()
myConnection.Close()
End Using
End Using
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
wow now I even tried this and its not working
Using myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("AGConnectionString").ConnectionString)
Using myCommand As New SqlCommand("SELECT UserId, ProfileName, RealName, Age from ag_profiles", myConnection)
myConnection.Open()
Dim dr As SqlDataReader = myCommand.ExecuteReader()
While (dr.Read())
UserIdLabel.Text = dr("UserId").ToString().Trim()
Response.Write(dr("UserId"))
'Spacing
Response.Write(" ")
Response.Write(dr("ProfileName"))
'Spacing
Response.Write(" ")
Response.Write(dr("RealName"))
'Spacing
Response.Write(" ")
Response.Write(dr("Age"))
'New Line
Response.Write("<br>")
End While
ListProfiles.DataSource = dr
ListProfiles.DataBind()
dr.Close()
myConnection.Close()
End Using
End Using
ASKER
My guess is the problem is starting here ---- Response.Write(dr("Field") )
How do you get the returned data to display in the repeater?
How do you get the returned data to display in the repeater?
ASKER
OK!!!! GOT THIS WORKING
Using myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("AGConnectionString").ConnectionString)
'Using myCommand As New SqlCommand("AGProfileSearchName", myConnection)
Using myCommand As New SqlCommand("SELECT UserId, ProfileName, RealName, Age from ag_profiles", myConnection)
'myCommand.CommandType = CommandType.StoredProcedure
myConnection.Open()
'myCommand.Parameters.AddWithValue("@SearchName", SearchName)
Dim dr As SqlDataReader = myCommand.ExecuteReader()
ListProfiles.DataSource = dr
While (dr.Read())
ListProfiles.DataBind()
End While
dr.Close()
myConnection.Close()
End Using
End Using
ASKER
THank YOUUUUu BRWWIGGINS
ASKER
Open in new window