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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:02:48+00:00 2026-05-23T16:02:48+00:00

I have this SQL Table: TABLE: Info COLUMNS:| Name | Value ——–|———-|—————— ROW: |

  • 0

I have this SQL Table:

TABLE: Info

COLUMNS:|   Name   |  Value
--------|----------|------------------
ROW:    |   Server |  255.255.255.255
ROW:    |   Host   |  212.212.212.212
ROW:    |   User   |  Admin

I’m selecting this table like that: SELECT * FROM Info

Now after I got all in this table.

I want to get the value Where Name = 'Server' and put it into the Server variable.

What is the best method to do it in C#?

DataSet? DataReader? And how can I accomplish this?


If you didn’t understand what I need here is another good explanation thx to Tim:

I’m trying to get a specified column’s value based on the value in another column of the same row

  • 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-23T16:02:49+00:00Added an answer on May 23, 2026 at 4:02 pm

    Based on your latest comments, it appears that you want to get all the rows in the table, and then be able to select a given row based on the Name column.

    A DataTable would be best if your program is going to need to access the different rows at different times – as long as the DataTable is in memory/cached, you can pull the value for any name at any time.

    If you just need to do it once, a SqlDataReader would probably be faster, but its forward-only.

    DataTable example:

    Assuming you’ve already filled the DataTable (name info in the example), you can use the Select method:

    DataRow[] selectedRows = info.Select("Name = 'Server'");
    
    string serverIP = selectedRows[0]["Value"].ToString();
    

    DateReader example:

    Based upon @Kobe’s code, simply check the Name each time you advance to the next record, and then pull the Value out:

    bool valueFound = false;
    
    while (reader.Read() && !valueFound)
    {
        if (reader["Name"].ToString() == "Server")
        {
           serverIP = reader["Value"].ToString();
           valueFound = true;
        }
     }
    

    There are some caveats to be aware of. First, the Select method of the DataTable returns an array of DataRow, so if more than one record has “Server” in the Name column, you’ll get multiple results. If that’s by design, that’s fine – just loop through the array of DataRows.

    Second, if there are a lot of rows in the table, or there is the potential down the road, the reader may be slower depending on where the record of interest is in the table. And if you’re dealing with the possibility of multiple records in the table matching the Name criteria, it’s probably easier all around to just stick with a DataTable.

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

Sidebar

Related Questions

I have a SQL Server 2005 table like this: create table Taxonomy( CategoryId integer
I have SQL Server 2008 with a table called ProductCategories designed like this: Id
I have this sql: ALTER TABLE dbo.ChannelPlayerSkins DROP CONSTRAINT FK_ChannelPlayerSkins_Channels but apparently, on some
I have this sql statement: CREATE TABLE [dbo].[User]( [UserId] [int] IDENTITY(1,1) NOT NULL, [FirstName]
I have an SQL table like this : sales(product,timestamp) I want to display a
If i have a sql table with column like this id version subversion 1
Hi there I have an SQL table that looks like this: CREATE TABLE IF
If i have a parameterized SQL statement like this: SELECT * FROM table WHERE
In MS Transact SQL, let's say I have a table (Orders) like this: Order
In SQL Server 2005, I have a table say tbl_Info. There I have one

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.