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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:29:18+00:00 2026-05-23T04:29:18+00:00

I am trying to do the text box autocomplete by using the code below,

  • 0

I am trying to do the text box autocomplete by using the code below, but it gives the error

ERROR :"Object reference not set to an instance of an object"

on this line:

for (int count = 0; count < dt.Rows.Count; count++)

Can anyone please help me?

private void tbMemberName_TextChanged_1(object sender, EventArgs e)
{
    tbMemberName.AutoCompleteMode = AutoCompleteMode.Suggest;
    tbMemberName.AutoCompleteSource = AutoCompleteSource.CustomSource;
    AutoCompleteStringCollection namec = new AutoCompleteStringCollection();

    //string search ="%"+ tbMemberName.Text +"%";
    //string @Name = tbMemberName.Text; 
    String sql =
        @"SELECT DISTINCT(member_Firstname +''+ member_Lastname) AS Name FROM members WHERE Name  Like '%'+tbMemberName.Text+'%'";
    DataTable dt = MemberFormHelper.GetData(sql, mf);
    if (dt.Rows.Count >= 0)
    {
        for (int count = 0; count < dt.Rows.Count; count++)
        {
            namec.Add(dt.Rows[count][Name].ToString());
        }
    }
    tbMemberName.AutoCompleteCustomSource = namec;
}
  • 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-23T04:29:19+00:00Added an answer on May 23, 2026 at 4:29 am

    dt is null, prolly (unless u have a record in ur table with the following name ‘tbMemberName.Text’)… I guess so – tbMemberName is a TextBox, so if you are trying to pass its value to the sql string instead of

    @"SELECT DISTINCT(member_Firstname +''+ member_Lastname) AS Name FROM members WHERE Name Like '%'+tbMemberName.Text+'%'";

    u have to write

    @"SELECT DISTINCT(member_Firstname +''+ member_Lastname) AS Name FROM members WHERE Name Like '%"+tbMemberName.Text+"%'";

    u have just misused quotation marks.

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

Sidebar

Related Questions

I am using tiny mce in a text box and trying to send emails.
I'm kind of like stuck trying to implement YUI autocomplete textbox. here's the code:
I am trying to implement a wpf user control that binds a text box
I'm trying to extend the TextBox , ComboBox and Panel controls using IExtenderProvider but
I have the following code and what I am trying to do is set
I've been trying to build a text box with a hint that's displaying while
I am trying to select the text from a text box and pass it
I have a text box in wxpython (see below) that stores the name of
I am using IE7. I have an input box as follows: <input name=location type=text
I am trying to ensure that the text in my control derived from TextBox

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.