Variable in SQL query

Results 1 to 2 of 2

Thread: Variable in SQL query

  1. #1
    Sharron Guest

    Default Variable in SQL query

    How can i use a variable in a SQL query<BR>eg.. Let " Selection " be a variable:<BR>Selection=Int(TotalRecord*rnd)+1<BR>R S.Open" SELECT * FROM tableZ WHERE ID = " & Selection<BR><BR>""""""""""""""""""""""""""<BR>is the above code correct? if yes then why does it not work?How can i use the variable "Selection" in the "WHERE" clause.<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Variable in SQL query

    What error msg do you recieve?<BR><BR>The below sql statement seems correct and "selection" has<BR>a valid value. Is the ID column in your table a column typ INT?<BR><BR>"SELECT * FROM tableZ WHERE ID = " & Selection<BR><BR>You will also need to specify the sql connection when you<BR>open the recordset.<BR><BR>RS.Open sqlText, sqlConnection<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts