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

  • Home
  • SEARCH
  • 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 8799361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:18:13+00:00 2026-06-14T00:18:13+00:00

From my ASP.NET application I want to issue this query to MySQL SELECT *

  • 0

From my ASP.NET application I want to issue this query to MySQL

SELECT * FROM responses WHERE field_id LIKE '3\_%'

In other words I am looking for records where the second character is the underscore literal character.

The code generated by the model designer looks like this:

    public virtual RiskAnalysis.responsesDataTable GetResponseGroupForAnalysis(int raid, string fieldid) {
    this.Adapter.SelectCommand = this.CommandCollection[2];
    this.Adapter.SelectCommand.Parameters[0].Value = ((int)(raid));
    if ((fieldid == null)) {
        throw new global::System.ArgumentNullException("fieldid");
    }
    else {
        this.Adapter.SelectCommand.Parameters[1].Value = ((string)(fieldid));
    }
    RiskAnalysis.responsesDataTable dataTable = new RiskAnalysis.responsesDataTable();
    this.Adapter.Fill(dataTable);
    return dataTable;
}

If I call this function like so:

string filter_string = @"3\_%";    
ResponsesAdapter.GetResponseGroupForAnalysis(10, filter_string);

the MySQL log reports the query to look like this:

SELECT     *
FROM         responses
WHERE     (ra_id = 10) AND (field_id LIKE '3\\_%')

In other words the I know I’m missing something blindingly obvious here, but how do I place MySQL’s escape backslash in the query without C# (un)helpfully escaping it?

  • 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-14T00:18:14+00:00Added an answer on June 14, 2026 at 12:18 am

    OK, it seems (by experiment – happy to hear explanation or documentation link) that in MySQL (field_id LIKE '3\_%'); is equivalent to (field_id LIKE '3\\_%'); and both will find records where field_id starts with ‘3_’. Got myself well confused there – thanks Mahmoud and René for trying to understand what I was getting at!

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

Sidebar

Related Questions

I am working on a ASP.NET application. I want to prevent the user from
so, I've got something like this: there's an ASP.NET application (1) that references WCF
In my asp.net web application i want to prevent multiple user login from the
I am trying to call a web service from asp.net 3.5 application. I have
As the title says, I am sending email from my ASP.net web application without
I tried upgrading an ASP.Net application from Visual Studio 2005 to 2008, and I
I have a ASP.NET application I've inherited from the person who did my job
I am working on asp.net application and I have generated entity model (edmx) from
I have an ASP.net application which returns a binary PDF file (stored from the
I'm generating a reporting services report from an ASP.NET (MVC) based application but am

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.