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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:27:41+00:00 2026-06-06T11:27:41+00:00

I have to compare a value in a string array to that of a

  • 0

I have to compare a value in a string array to that of a particular column in a database. How do i do this ?

  public void setvisibility(string user_ID)
{
    SqlDataReader reader = null;
    SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["ctd_prrity_dbConnectionSting"].ConnectionString);
    connection.Open();\
SqlCommand cmd = new SqlCommand("Select * from Admins );

I need to compare the value of user_ID to the only column in the Admins table !

  • 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-06T11:27:42+00:00Added an answer on June 6, 2026 at 11:27 am

    Here’s how you can do it:

    using( SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["ctd_prrity_dbConnectionSting"].ConnectionString))
    { 
      connection.Open();   
      SqlCommand cmd = new SqlCommand("Select 1 from Admins where User_ID=@userid",connection );
      cmd.Parameters.AddWithValue("@userid",user_ID);
      SqlDataReader reader= cmd.ExecuteReader();
      if(reader.HasRows)
      {
       //user id found
      }
    }
    

    This method uses a parametrized queries, which are safer than the option given in the answer by Tony since his is prone to SQL Injection attacks.

    BTW: you mention “string array” in your question, yet your code only shows a single string as parameter. What did you mean by that?

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

Sidebar

Related Questions

I wrote a serializer (to Byte Array) for dictionaries that have a string key,
I have 3 values that I want to compare f, g and h. I
I have a function, that returns the next higher value of a Dictionary-Keys-List compared
I have this code: # Compare phone number phone_pattern = '^\d{3} ?\d{3}-\d{4}$' phoneNumber =
i have used dictionary to collect the array of values i have value in
I have this select $this->db->select('modulo_regra.regra_descricao'); $this->db->from('modulo_regra'); $this->db->where('modulo_regra.modulo_regra_id', id); $query = $this->db->get(); that return to
I have this html code test.html : <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
Hi I have an array that stores when radio buttons are checked so that
Say I have a Song object like public Song(){ String artist, title; StringBuilder lyrics;
I have two questions: 1. How to break a string into an array given

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.