Forums
 This topic is locked 
             Using a variable in a t sql command line
 Posted 18 Mar 2001  15:36:25 
  1 
     has   voted 
  18 Mar 2001  15:36:25 Michael Moore posted: 
 ok here is the commandset VistaCollateral = Server.CreateObject("ADODB.Recordset"

VistaCollateral.ActiveConnection = MM_connCollateral_STRING
VistaCollateral.Source = "SELECT * FROM VistaCollateral WHERE Category LIKE svMnuCategory ORDER BY ProductID ASC"
-------left out the next few lines------
now, MS says this error is because column does not exist in the table. It does. If i do this command without a var... say a real value of svMnuCategory, it works fine. if i response.write the rsVista.source it is showing the svMnuCategory literally instead of seeing the value of the var svMnuCategory.
(using response.write).
Is it not possible to use a var in a t sql source command line? anybody know?
%>
Edited by - ecsmoore on 03/18/2001 15:52:12
Replies
 Replied 18 Mar 2001  16:13:41 
   18 Mar 2001  16:13:41 Michael Moore replied: 
  never mind, i see my errors. the command source is quoted literal text therefore it has not way to know the svMnuCategory is a variable. i will have to go back and construct the command line in previous code.
  
   Replied 18 Mar 2001  19:25:32 
   18 Mar 2001  19:25:32 Michael Moore replied: 
  [n case anyone is interested, here is the command line to fix the original problem.
VistaCollateral.Source = "SELECT * FROM VistaCollateral WHERE Category LIKE " +"'" + svMnuCategory +"'" + " ORDER BY ProductID ASC"
]
never mind, i see my errors. the command source is quoted literal text therefore it has not way to know the svMnuCategory is a variable. i will have to go back and construct the command line in previous code.
 
  
  VistaCollateral.Source = "SELECT * FROM VistaCollateral WHERE Category LIKE " +"'" + svMnuCategory +"'" + " ORDER BY ProductID ASC"
]
never mind, i see my errors. the command source is quoted literal text therefore it has not way to know the svMnuCategory is a variable. i will have to go back and construct the command line in previous code.