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 8653005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:26:20+00:00 2026-06-12T14:26:20+00:00

I have a table in my sql database, that comtains data. In this table,

  • 0

I have a table in my sql database, that comtains data.
In this table, I have the id (int), and two two column names (each nvarchar(50) ).
Now. Say. Using C# in codebehind, I want to place one of the “nvarchar” in a string.
I wish to use the id from my browsers url, to choose the data with.

Lets say, my url is “http://localhost:49530/Forum/Thread.aspx?id=4”
In my table, I have ThreadID, Topic and Message.
So it needs to write the data from “Topic”, that has ThreadID=4, into a predefined variable.

I wish to do it in page_load in code behind. And finally show that data in a label on the aspx page.

I am totally blank. (as well as what to google for. Have googled the whole day on this).

I have cooked some code now, using the example given to me. Something is wrong.

SqlConnection conn_Kategori = new SqlConnection(WebConfigurationManager.ConnectionStrings["Computer_Klubben_CommunitySiteConnectionString"].ConnectionString);
int TraadVaelger = int.Parse(Request.QueryString["id"]);
string OutputToLabel;

    using (conn_Kategori)
    {
        conn_Kategori.Open();
        SqlCommand OverfoerTraadNavnet = new SqlCommand("SELECT KatNavn FROM KategoriTabel WERE Katnavn = @KatNavn", conn_Kategori);
        OverfoerTraadNavnet.CommandType = CommandType.Text;
        OverfoerTraadNavnet.Parameters.AddWithValue("@KatNavn", TraadVaelger);
        OverfoerTraadNavnet.ExecuteReader();
        OutputToLabel = OverfoerTraadNavnet.ExecuteReader().ToString();
        Stien.Text = OutputToLabel;
        conn_Kategori.Close();
    }
  • 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-12T14:26:21+00:00Added an answer on June 12, 2026 at 2:26 pm
    string OutputToLabel = string.Empty;
    
    if(!string.IsNullOrEmpty(Request.QueryString["id"]))
    {
        int ThreadID = 0;
        int.TryParse(Request.QueryString["id"], out ThreadID);
        if(ThreadID > 0)
        {
            string Sql = "SELECT Topic FROM <tablename> WHERE ThreadID = @ThreadID;";
            using (SqlConnection conn = new SqlConnection(connString))
            {
                SqlCommand cmd = new SqlCommand(Sql, conn);
                cmd.Parameters.Add("@ThreadID", ThreadID);
                try
                {
                    conn.Open();
                    OutputToLabel = cmd.ExecuteScalar().ToString();
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQL Server 2008 database with a table that has a column
I have a SQL Server database table with a column called resources. Each cell
I have a SQL Server 2005 database that stores data for multiple users. Each
Ok I have a table in my SQL Server database that stores comments. My
I have a SQL database that has a table with a field set to
I have a SQL database that has the following table: Table: PhoneRecords -------------- ID(identity
I have a junction table in my SQL Server 2005 database that consist of
I have a table in SQL database: ID Data Value 1 1 0.1 1
I have a table with data from an SQL database and the table exists
I have a table like this in my database (SQL Server 2008) ID Type

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.