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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:24:07+00:00 2026-06-01T06:24:07+00:00

I try to get one data column from a MS-Access table and display it

  • 0

I try to get one data column from a MS-Access table and display it in a TextBox like this

public partial class Form1 : Form
{
    public OleDbConnection database;

    public Form1()
    {
        InitializeComponent();
    }

    private OleDbConnection Database_Connection;

    private void Open_Database_button_Click(object sender, EventArgs e)
    {
        Database_Connection = new OleDbConnection(
            "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="test.mdb");
        OleDbCommand Command = new OleDbCommand(
            " SELECT top 1 * from test", Database_Connection);
        Database_Connection.Open();
        OleDbDataReader DB_Reader = Command.ExecuteReader();

        // How can I display the column in TextBox?
    } 

    ...
}
  • 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-01T06:24:09+00:00Added an answer on June 1, 2026 at 6:24 am

    Try to change your Open_Database_button_Click in this way:

    private void Open_Database_button_Click(object sender, EventArgs e) 
    { 
        using(OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=test.mdb" )) 
        using(OleDbCommand Command = new OleDbCommand(" SELECT top 1 * from test", con)) 
        {
           con.Open(); 
           OleDbDataReader DB_Reader = Command.ExecuteReader(); 
           if(DB_Reader.HasRows)
           {
              DB_Reader.Read();
              textbox1.Text = DB_Reader.GetString("your_column_name");
           }
        }  
    }
    

    What I have changed/added:

    • Removed the global var DataBase_Connection
    • Added using to the Disposable objects, so they will automatically
      closed when no more needed
    • Added check on DB_Reader.HasRows to exclude empty results from the
      query
    • Added setting of the text property of the textbox with the value of
      one of your columns
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have SP that selects data from a table with two columns like this
When I try to remove the last row from a single column data frame,
I have a table like this: | X | Y | Data | ----------------
I try to update a column in a temporary table by concatenating rows from
I've got a table one column of which uses an NSPopUpButtonCell. Try as I
Hello guys i try to get an object global/persistent over more than one php
I try to get to a page straight from Bash at http://www.ocwconsortium.org/ . The
I try to get this following url using the downloadURL function as follows: http://www.ncbi.nlm.nih.gov/nuccore/27884304
Using jQuery I get JSON object that extracts one row from database. That row
I have some data from an old table, with a lot of columns that

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.