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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:32:46+00:00 2026-06-17T08:32:46+00:00

I would like to use two different textboxes to filter information from a database

  • 0

I would like to use two different textboxes to filter information from a database to display baseball players average score. Example selecting 0,3 to 0,4, should display players with scores between these number.

Whats not working is the following code:

// Search for player, working
private void button1_Click(object sender, EventArgs e)
        {
            view.RowFilter = "LastName like '%" + textBox1.Text + "%'";
            if (textBox1.Text == "") view.RowFilter = string.Empty;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            DataTable datatable = new DataTable();
            SqlConnection connection = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Mattias\Dropbox\C#\Database\Baseball.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
            connection.Open();
            datatable.Load(new SqlCommand("select * from players", connection).ExecuteReader());
            dataGridView1.DataSource = view = datatable.DefaultView;
            connection.Close();
        }
// This button is not working
        private void button2_Click(object sender, EventArgs e)
        {
            decimal minimum = Convert.ToDecimal(textBox2.Text);
            decimal maximum = Convert.ToDecimal(textBox3.Text);
// Should display players with different scores
            view.RowFilter = String.Format("BattingAverage >= {0} AND BattingAverage <= {1}"
                , minimum, maximum);

            if (textBox2.Text == "") view.RowFilter = string.Empty;
            if (textBox3.Text == "") view.RowFilter = string.Empty;
        }
  • 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-17T08:32:47+00:00Added an answer on June 17, 2026 at 8:32 am

    RowFilter does not support the BETWEEN operator. It also doesn’t support complete sql queries like yours. However, you can specify the WHERE-clause there to filter the rows of the view:

    view.RowFilter = String.Format(CultureInfo.InvariantCulture.NumberFormat,
                     "BattingAverage >= {0} AND BattingAverage <= {1}", minimum, maximum);
    

    I’ve used InvariantCulture.NumberFormat in String.Format to ensure the english format(dots as decimal separator) in RowFilter which is required.

    Note that you also have wrapped the values with apostrophes which is not allowed on numbers and that you’re using textBox2.Text as input for your minimum and maximum value.

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

Sidebar

Related Questions

I would like to use two different implementations for a DAO with Spring's testframework.
I have two graphs with different scale and I would like to use subplot.
I have two different views to the same database table and I would like
I would like to use same ComplexType in two different WSDLs. How to define
I'd like to use convert (or whatever) from Imagemagick to combine two different sized
I would like to use two different insert statements with two different tables such
I would like to use two models: User: - firstname : stringField - lastname
I would like to use a UISegmentedControl with two buttons as a replacement for
I would like to use CSS to present a two-column layout. The markup I
I would like to use the logout function from Django but not sure how

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.