none
Trivial question in ADO.net RRS feed

  • Question

  • Hello,

     

    I want to connect with MS SQL Server 2005 through ADO.net in C#.

    In my database, I have a column called ID of type CHAR(256) in table PEOPLE.

     

    At first, I compared the ID with a string, it works:

    SqlCommand cmdPeople = new SqlCommand("select ID_NUMBER from PEOPLE where ID = '01058eb18b' ", conn);

     

    Then, I want to use a variable string, it does not work:

    string tagid = "01058eb18b";

    SqlCommand cmdPeople = new SqlCommand("select ID_NUMBER from PEOPLE  where ID = ' &tagid& ' ", conn);

     

    How can I write this part correctly: where ID = ' &tagID& '

     

    Thank you in advance!!

    Wednesday, April 2, 2008 4:11 PM

Answers

  •  

    Code Snippet

    SqlCommand cmdPeople = new SqlCommand("select ID_NUMBER from PEOPLE  where ID = '" + tagid + "' ", conn);

     

    Wednesday, April 2, 2008 4:34 PM