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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:46:18+00:00 2026-05-31T00:46:18+00:00

Hello and good day to all. I have a little question about like statement

  • 0

Hello and good day to all. I have a little question about like statement of sql/c#, I can’t figure out why my code doesn’t work.

if (Combo_List.Text == "What")
{
   listView1.Items.Clear();
   myds.Clear();
   mydaEvents.SelectCommand = myconn.CreateCommand();
   mydaEvents.SelectCommand.CommandText = "select * from Eventstbl where What like '@what%'";
   mydaEvents.SelectCommand.CommandType = CommandType.Text;
   mydaEvents.SelectCommand.Parameters.Add("@what", SqlDbType.NVarChar, 2000, "What").Value = text_Search.Text;
   mydaEvents.Fill(myds, "Eventstbl");

   foreach (DataRow item in myds.Tables["Eventstbl"].Rows)
   {
       ListViewItem items = new ListViewItem(item["EventsID"].ToString());
       items.SubItems.Add(item["What"].ToString());
       listView1.Items.Add(items);
   }
}

The @what% won’t work but when I put ‘a%’ all items that begin in letter a shows in my listview1. I don’t know how to fix this issue. help me please. Thank you 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-05-31T00:46:20+00:00Added an answer on May 31, 2026 at 12:46 am

    Try this:

    mydaEvents.SelectCommand.CommandText = "select * from Eventstbl where What like @what + '%'";
    

    Text inside quotes will be treated as…text – you want your parameter to be interpreted as its string value, so you have to move it out.

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

Sidebar

Related Questions

Hello and good day to all. I have the following code to retrieve from
Hello and good day to all. I have an issue on coding, i have
I have this string @[123:peterwateber] hello! good day! I wanna change it to <a
I have this little text <div> Hello world<br> this is a good<br> text! <br><br>
Hello and good day to you. Following code fragment compiles on cl.exe (15.00.30729.01) and
Hello good Stack Overflow people, I do have a business problem and would like
I have a file abc.txt with contents like: hello hi good bad ... ....
Hello good people of Stack Overflow, I have come with yet another question for
I have a about 500.000 rows in database and they are look like: :hello:hi:
Hello good fellas i'm sure everybody is cool.I'm about to start a tutorial about

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.