LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Using a number variable in an SQL statement

Hi,

 

I am trying to use a variable in an sql statement and I have run into problems when the variable is a number. The following line of code works if the variable is a string but not if it is a number.

 


"SELECT TOP 1 UUT_STATUS FROM UNIT_UUT_RESULT WHERE UnitID =  '" + Locals.LocalUnitID + "' ORDER BY START_DATE_TIME DESC"

 

Is there a difference in the use of the single and double quotes and the + sign for number variables?

 

Thanks

 

Stuart

0 Kudos
Message 1 of 3
(2,836 Views)

I'm no expert but I don't believe you need to surround a number within the single speech marks but text does need them. i.e. items in red are not needed.

 

"SELECT TOP 1 UUT_STATUS FROM UNIT_UUT_RESULT WHERE UnitID =  '" + Locals.LocalUnitID + "' ORDER BY START_DATE_TIME DESC"

 

Kevin

0 Kudos
Message 2 of 3
(2,823 Views)

Duplicate Thread

 

Stuart is right, refer to my post on the TestStand forum:
http://forums.ni.com/ni/board/message?board.id=330&thread.id=22694

 

Jervin Justin
NI TestStand Product Manager
0 Kudos
Message 3 of 3
(2,818 Views)