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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:26:24+00:00 2026-05-22T14:26:24+00:00

I Have a problem with a prepared statement in C#: OdbcCommand cmd = sql.CreateCommand();

  • 0

I Have a problem with a prepared statement in C#:

OdbcCommand cmd = sql.CreateCommand();
cmd.CommandText = "SELECT UNIQUE_ID FROM userdetails WHERE USER_ID = ?";
cmd.Parameters.Add("@USER_ID", OdbcType.VarChar, 250).Value = email;

(of course email contains a valid email address, with @ sign).

This code returns a random error –

“The connection has been disabled”
{“ERROR [01000] [Microsoft][ODBC SQL
Server Driver][TCP/IP
Sockets]ConnectionWrite (send()).
ERROR [08S01] [Microsoft][ODBC SQL
Server Driver][TCP/IP Sockets]General
network error. Check your network
documentation.”}

However if I run my code without a prepared statement, meaning:

cmd.CommandText = "SELECT UNIQUE_ID FROM userdetails WHERE USER_ID = '"+email+"'";

Everything works perfectly.

Maybe it’s related to the fact that I have a @ sign in the parametrized value? I tend to think I’m not the first one trying to create a prepared statement with an email address…

I have no idea what’s wrong! Other prepared statements work normally…

Can you please help? 🙂
Thanks,
Nili

  • 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-22T14:26:25+00:00Added an answer on May 22, 2026 at 2:26 pm

    Indeed, ODBC has its share of issues with supporting named parameters.
    However, certain usage of named parameters is possible.

    For example, in your case the following syntax works:

    OdbcCommand cmd = sql.CreateCommand();
    cmd.CommandText = "SELECT UNIQUE_ID FROM userdetails WHERE USER_ID = ?";
    cmd.Parameters.Add("USER_ID", OdbcType.VarChar, 250).Value = email;
    

    More tricky situation is when you don’t have a unique match for the parameter like USER_ID = ?; e.g., when you want to use the IN operator in the WHERE clause.

    Then the following syntax would do the job:

    OdbcCommand cmd = sql.CreateCommand();
    cmd.CommandText = "SELECT UNIQUE_ID FROM userdetails WHERE USER_ID IN (?, ?)";
    cmd.Parameters.Add("?ID1", OdbcType.VarChar, 250).Value = email1;
    cmd.Parameters.Add("?ID2", OdbcType.VarChar, 250).Value = email2;
    

    Please note the usage of ? (question mark) instead of @ (at sign) within the parameter name. Although note that substitution of parameters’ values in this case has nothing to do with their names, but only with their order with the parameters collection.

    I hope this helps 🙂

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

Sidebar

Related Questions

I have the problem with a prepared statement like this: select ... from ...
I have a problem where my prepared statement appears to only be returning the
I have a prepared statement. I call stmt.setBigDecimal(BigDecimal.valueOf(0.9)) the problem is that in the
I have a problem with long numbers in prepared statement. Here is the code:
I am having a strange problem. I am using PDO prepared statement. I have
I have problem in some JavaScript that I am writing where the Switch statement
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I have my input placed into mySQL through a PDO prepared statement, and have
I have a prepared statement: PreparedStatement st; and at my code i try to
I have this partial code: if ($getRecords = $con->prepare(SELECT * FROM AUCTIONS WHERE ARTICLE_NO

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.