Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8631849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:16:25+00:00 2026-06-12T09:16:25+00:00

I have a C# SQL query for my asp.net page which queries the database

  • 0

I have a C# SQL query for my asp.net page which queries the database using a value stored in the session of my page (called tournyName). I have the query working, and I am using a SqlDataReader (called myReader) to read the results of the query. I cant however get the results to display on the HTML area of my page.
I have been piecing together bits of code that I have found from other peoples questions and the code at this point is incomplete. It looks something like this:

C# (snppit):

    conn.Open();
    query = "SELECT GamePlayer1 AS [Player 1], GamePlayer2 AS [Player 2], GamePlayer1Score AS [Score1], GamePlayer2Score AS [Score2] FROM Games WHERE (TournyName = '@TournyName')";

    com = new SqlCommand(query, conn);

    com.Parameters.Add(new SqlParameter("@TournyName", SqlDbType.VarChar, 200));
    com.Parameters["@TournyName"].Value = Server.HtmlDecode(tournyName.Trim());

    SqlDataReader myReader;
    myReader = com.ExecuteReader();
    myRepeater.DataSource = myReader;
    myRepeater.DataBind();

And my HTML, where I would like to display the results:

<asp:Repeater id="myRepeater" runat="server">
<HeaderTemplate><table border="1"></HeaderTemplate>
<ItemTemplate>
<tr><td>
</td>
<td>
<%# Eval('Player 1')%>
</td>
<td>
 <%# Eval('Player 2')%>  
<td>
 <%# Eval('Score1')%>  
</td>
<td>
 <%# Eval('Score2')%>  
</td>
</tr>
</ItemTemplate>
<FooterTemplate></table></FooterTemplate>
</asp:Repeater>

No matter what I try, the page just shows up as blank. Can anybody enlighten me as to how I would display this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:16:25+00:00Added an answer on June 12, 2026 at 9:16 am

    There are a couple of things:

    • Since you are using a parameter (good!), you mustn’t escape the parameter token in the SQL Query with quotes, i.e. just

    SELECT GamePlayer1 AS [Player 1], GamePlayer2 AS [Player 2], GamePlayer1Score AS [Score1],
    GamePlayer2Score AS [Score2] FROM Games WHERE (TournyName = @TournyName)

    • Eval needs double quotes, i.e. <%# Eval("Player 1")%>

    Also, remember to Dispose your connection, command and SQLReader.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL query I'm running in an ASP.NET page. The final parsed
I'm using ASP.net and an SQL database. I have a blog like system where
I have a SQL query in my ASP.net web app that looks like this:
I have a boolean variable value stored in an SQL Server database. This is
Old hand at ASP.NET, new to the UpdatePanel. I have a reporting page which
Summary We have an ASP.NET application that allows users to query a SQL Server
I have a process in a website (Asp.net 3.5 using Linq-to-Sql for data access)
I've been developing a ASP.NET page and have been using LINQ to handle talking
I have a asp.net page in which I have a chart that I dragged
I am creating an asp.net page which loads data from a (SQL) visual studio

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.