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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:51:31+00:00 2026-05-14T02:51:31+00:00

In PHP I am able to retrieve information from a db like so: <?php

  • 0

In PHP I am able to retrieve information from a db like so:

<?php
    $sql = "SELECT * FROM users";
    $result = mysql_query($sql);
    $data = array();
    while($row = mysql_fetch_assoc($result))
    {
        $data[] = $row;
    }

I am trying to acomplish the same thing in C#:

OdbcCommand cmd = new OdbcCommand("SELECT * FROM users WHERE id = @id");
        cmd.Parameters.Add("@id", id);
        OdbcDataReader reader = cmd.ExecuteReader();
        Dictionary<string, string> data = new Dictionary<string, string>();
        while (reader.Read())
        {
            data.Add("id", reader.GetString(0));
            data.Add("username", reader.GetString(1));
            data.Add("firstName", reader.GetString(2));
        }
        return data;

Is it possible to reference the column in the table by name without going through all this trouble?

  • 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-14T02:51:32+00:00Added an answer on May 14, 2026 at 2:51 am

    You can use the OdbcDataAdapter class to populate a DataSet, which would probably be a bit simpler.

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

Sidebar

Related Questions

I am able to retrieve information from a SQLite database in PHP, but not
I'd like to be able to use php search an array (or better yet,
$result = $db_con->query(SELECT SQL_CALC_FOUND_ROWS * FROM users LIMIT 0,10); $count_result = $db_con->query(SELECT FOUND_ROWS() as
I have sessions on 3 individual pages: teacherlogin.php (page 1) while($row = mysql_fetch_array($result)) {
i would like to be able to retrieve results from this search by connecting
I'd like to be able to write a PHP class that behaves like an
I would like to be able to start a second script (either PHP or
I need to be able to periodically send email alerts to subscribed users. PHP
I'm trying to retrieve information(descriptionand Mail) from my active directory without knowing my DN
I'm new to PHP and Zend, and I would like to cache sensitive data

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.