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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:31:08+00:00 2026-05-27T02:31:08+00:00

Assume that you have this code in C#/.NET (using PostgreSQL via ODBC): using System.Data.Odbc;

  • 0

Assume that you have this code in C#/.NET (using PostgreSQL via ODBC):

using System.Data.Odbc;
...
OdbcCommand cmd = ...;
cmd.CommandText = "SELECT id, email, password FROM users WHERE email=?;";
cmd.Parameters.Clear();
cmd.Parameters.Add("email", OdbcType.VarChar).Value = aEmail;

But when aEmail == \’ (backslash and apos.) then it gives me following error:

Exception type: OdbcException 
Exception message: ERROR [42601] ERROR: unterminated quoted string at or near "'\''';";
Error while executing the query

As I’ve read, using OdbcCommand.Parameters should protect against SQL injection, but in this case it looks like something doesn’t works right, what am I missing?

Important note: I’ve never used PostgreSQL, ODBC, .NET before (started today, but I hope to end it today too ;), but I need to fix 4 SQL queries in one simple web application – previously there was:

System.Format("SELECT ... email = {0}", aEmail)
  • 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-27T02:31:09+00:00Added an answer on May 27, 2026 at 2:31 am

    Are you trying to escape the single quote? the problem is that to escape the single quote in PostgreSQL you should escape it with another single quote and not with backslash :

    ''''
    

    However the ODBC driver should do this for you automatically passing only the single quote… Try to update with the latest version of the ODBC driver, if the problem persist maybe it is better to open an issue to the postgreSQL bug mailing list .

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

Sidebar

Related Questions

Assume that I have this piece of code: @interface Foo : NSObject { Bar
I have C# .NET code with a DataSet (System.Data.DataSet) containing one table of data,
Assume I have a class that looks like this: class Sample { public string
Assume that I have the ItemSource bound and i am getting the data. Now
Assume that we have the following code: class Program { static volatile bool flag1;
I have some C# code that walks XML schemata using the Xml.Schema classes from
I have a .NET MVC (1.0) application that is using the ActiveDirectoryMembershipProvider to authenticate
I'm trying to build System.Data.SQLite in Visual Studio using the source code downloaded from
I do not have any code to show, but using asp.net, vb.net, and SQL
Assume that we have N erlang nodes, running same application. I want to share

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.