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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:48:25+00:00 2026-06-17T03:48:25+00:00

Im trying to populate a text box with infromation that is searched by using

  • 0

Im trying to populate a text box with infromation that is searched by using a customerID which is inputted throught a text box here is the code im using below

private void txtCustomerID_TextChanged(object sender, EventArgs e)
{
    string strCon = Properties.Settings.Default.PID2dbConnectionString;
    OleDbConnection conn = new OleDbConnection(strCon);

    String sqlPoints = "SELECT points FROM customer WHERE [customerID]=" +   txtCustomerID.Text;
     txtPoints.Text = sqlPoints;
}

but the text box “txtPoints” only outputs the text of the sqlpoints and not the information in the database? I’m not exactly sure what im doing wrong here.

Any help is appreciated, 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-06-17T03:48:27+00:00Added an answer on June 17, 2026 at 3:48 am

    You are not executing the SQL statement on the database. Instead, you are assigning it to txtPoints.Text. You need to execute it on the DB server using, e.g., an OleDbCommand object.

    What you need to do instead is something like the following (note this is pseudo-code – I haven’t tested it runs)

    using (OleDbConnection conn = new OleDbConnection(strCon))
    {
        String sqlPoints = "SELECT points FROM customer WHERE [customerID]=" +   txtCustomerID.Text;
    
        // Create a command to use to call the database.
        OleDbCommand command = new OleDbCommand(sqlPoints, conn)
    
        // Create a reader containing your results
        using(OleDbReader reader = command.ExecuteReader()) 
        {
            reader.Read(); // Advance to the first row.
            txtPoints.Text = reader[0].ToString(); // Read the contents of the first column
        }
    }
    

    Note also my use of using. This will ensure that your database connections are properly closed once you are finished with them.

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

Sidebar

Related Questions

I'm trying to populate a rich text box line by line with txt file...
I am trying to populate a text box with some data, namely the names
I have the jquery below which basically pre-populates a text box. (It actually populates
I am trying to populate a text box based on the values from a
I'm trying to populate an HTML text box with a php variable. The variable
I'm trying to run a script on an input text box that populates a
I am trying to populate a text box on a form by clicking on
I am trying to auto-populate a text field based on the value of another
I am trying to populate an array with the text value of a json
I am trying populate H3 with the sum of column E for rows 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.