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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:54:52+00:00 2026-06-09T23:54:52+00:00

I have a masked textbox in c# winform. The masking would be like –

  • 0

I have a masked textbox in c# winform.

The masking would be like

 - (two numbers on the front and 4 number on the right after the dash).

for ex: 12-3456

There are more permutations like

   - (3 spaces on the front and 5 on the right)

for ex: 123-34567

When a user types 123-34567, the select sql query should return only

123-34567

When a user types 12-3456, the select sql query should return only

12-3456

When a user types   -, the select sql query should return
only

12-3456 (ie. two spaces typed)

When a user types    -, the select sql query should
return only

123-34567 (ie. three spaces typed)

In other words, a user can search without entering anything and have
only mask enabled text box and
search(empty – empty) – only dash mask , type number(s) on the
mask and search (for ex: 12- ).

The query am using is

select column1,column2 from table1 where column2 like '%__-%';

(the underscores are dymanically calculated) and how do i get this in any other optimum approach (say like in a single query) ?

Consider this table1 and having a column “MaskedInfo” in the database.

Table1:

MaskedInfo  

1234567
12-34567
123-4567
123-45678

User can type anything to search like 12-34567 or 123-4567 or simply
1234567 and if the text box is empy load everything in the result.

  • 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-09T23:54:54+00:00Added an answer on June 9, 2026 at 11:54 pm

    The problem seems to be the first %, you’re changing the spaces int he user input for underscores, there you’re right but the first % will get you results with something before the underscores,
    so

    like '%__-%'  //(two underscores) 
    

    will get anything that has two or more digits before the -,

    like '%___-%'  //(three underscores) 
    

    will get anything that has three or more digits before the –

    removing the first % will get the result that have exactly as many digits as underscores

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

Sidebar

Related Questions

I have two masked TextBox controls and was wondering how I'd go about getting
i have a textbox associated with a calendar extender and a masked edit extender
I have a class that is marked with DataContract attributes and I would like
I have a masked textbox on my winforms application where if a user clicks
I load files to a TextBox, and I would like some of the information
I have two text boxes which is loaded with jquery masked date input .
I have a masked textbox with the Mask: 0000 applied to it. The problem
I have a masked textbox with the need to have a min/max length set
I have to read/write an XML file that stores its data as bit masked
I have a textbox databound to a nullable int through code. If I erase

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.