|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to compare a variable against an sql bit field
compare against a bit field. the sintaxis used was: if (rs_cu("bt_nac") <> 1) then ....... I made the query using the query analyzer and saw that the field value was NULL so I made the question if (rs_cu("bt_nac") = NULL) then ........ Either of both questions the program flow via Else instead the condition were attained. Help appreciatted. PD: The SQL construction is shown below: 1.- SQL = "SELECT carrito.*, Productos.ca_producto AS ca_producto, Productos.co_imp_iva AS co_imp_iva, Productos.nu_peso AS nu_peso," SQL = SQL & " Productos.nu_dim_alto AS nu_dim_alto, Productos.nu_dim_largo AS nu_dim_largo, Productos.nu_dim_ancho AS nu_dim_ancho, Productos.bt_nac AS bt_nac" SQL = SQL & " FROM carrito INNER JOIN" SQL = SQL & " Productos ON Productos.co_producto = carrito.co_producto" SQL = SQL & " WHERE (carrito.id_session = " & session.SessionID & ")" 2.- The query result was (the last field was bt_nac): 2069 783347814 37313 1 2006-09-12 00:43:16.700 22500.0000 4500.0000 0 0 NULL 0.69999999 5.5 10.5 10.5 NULL Mirovk wrote:
Show quote > I am having problems making a comparison into my asp program In VBScript, Null in either operand returns Null:> when I compare against a bit field. > > the sintaxis used was: > > if (rs_cu("bt_nac") <> 1) then ....... > > I made the query using the query analyzer and saw that the > field value was NULL so I made the question > > if (rs_cu("bt_nac") = NULL) then ........ > > > Either of both questions the program flow via Else instead > the condition were attained. http://msdn.microsoft.com/library/en-us/script56/html/adb6e3ac-d925-4987-9d43-f6486d5f1e30.asp Use IsNull() to test for Null: http://msdn.microsoft.com/library/en-us/script56/html/c6a16689-8b58-48ec-af0b-41faf888afc1.asp An alternate approach is to use the SQL ISNULL function to return a default value (I am assuming SQL Server): SELECT ..., ISNULL(Productos.bt_nac,0) AS bt_nac ... http://msdn.microsoft.com/library/en-us/tsqlref/ts_ia-iz_6mek.asp -- Dave Anderson Unsolicited commercial email will be read at a cost of $500 per message. Use of this email address implies consent to these terms. |
|||||||||||||||||||||||