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

  • Home
  • SEARCH
  • 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 7688283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:53:04+00:00 2026-05-31T19:53:04+00:00

Hi can you help me with this?? I have this code and i want

  • 0

Hi can you help me with this??

I have this code and i want to display the result of my query into my 3rd Textbox but it not displaying.

string query = "SELECT UserID FROM [IBSI].[sec].[Users] WHERE UserName = '" + TextBox2.Text + "'";

if (query != null)
{
  using (SqlConnection conn = new SqlConnection(connect))
  {
    using (SqlCommand cmd = new SqlCommand(query, conn))
    {

      conn.Open();
      SqlDataReader rdr = cmd.ExecuteReader();
      if (rdr.HasRows)
      {
        while (rdr.Read())
        {

         TextBox3.Text=rdr["UserID"].ToString() ;


        }
      }
    }
  }
}

But then i just use this query without the where condition i can see the output;

string query = "SELECT UserID FROM [IBSI].[sec].[Users]";

Thanks in advance

  • 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-05-31T19:53:05+00:00Added an answer on May 31, 2026 at 7:53 pm

    I’d recommend using parameterized queries for this task. Also, generating sql code from user input (like text boxes/memos) is prone to sql injections (user may enter any sql code into the textbox that may damage database data), so it’d be great to validate input data.

    Sample parameter usage is like this:

    string query = "SELECT UserID FROM [IBSI].[sec].[Users] WHERE UserName = @1";
    if (query != null)
    {
        using (SqlConnection conn = new SqlConnection(connect))
        {
            using (SqlCommand cmd = new SqlCommand(query, conn))
            {
                SqlParameter p1 = new SqlParameter("@1", TextBox2.Text);
                cmd.Parameters.Add(p1);
                conn.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows)
                {
                    while (rdr.Read())
                    {
                        TextBox3.Text=rdr["UserID"].ToString() ;
                    }
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Dear everybody who can help, I have this PHP > MongoDB problem, I want
can you please help me with this issue the String class does not have
I wonder if anyone can help - I have this error showing recently when
Heyy can somebody help me ? i have this issue that still do know
I hope some of you guys can help me with this problem.... I have
Can anybody please help me with this as I have no idea why public
can someone help me with this? I have an AlertDialog box and its working
I hope you can help. This has been confounding me for hours. I have
I was wondering if someone can help me out with this issue. I have
i am a beginner in PHP.I have this query in my code. $qsq =

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.