locked
how i can compare id as integer value stored in access with a query value that is in string RRS feed

  • Question

  • User2095221599 posted

    how i can compare id as integer value stored in access with a query value that is in string i am getting an error message 

    data type  mismatch i m using           where id = ' "+label1.text +" '

    thanks in anticipation  



    Saturday, January 29, 2011 7:21 AM

Answers

All replies

  • User-693248168 posted

    Give this command

    where id =  "+label1.text +" 


    i.e. dont give the single quotes before and after the ID value.


    Saturday, January 29, 2011 11:27 AM
  • User-1199946673 posted

    Start using parameterized queries:

    http://www.mikesdotnetting.com/Article/26/Parameter-Queries-in-ASP.NET-with-MS-Access

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, January 29, 2011 6:25 PM
  • User1867929564 posted

    where id = =  "+Convert.ToInt32( label1.text) +" 

    Monday, January 31, 2011 6:49 AM
  • User-821857111 posted

    where id = =  "+Convert.ToInt32( label1.text) +" 

    That's worse than the first reply in that it doesn't even use valid SQL. The Convert.ToInt is totally unnecessary as the SQL statement to be executed is a string, so it will be converted back to a string when it is concatenated.

    Hans is right. The OP's problem will be solved by using parameter queries, and they will be following recommended practice too.


    Tuesday, February 1, 2011 5:59 PM