SQL Update - Sending Null values 
Author Message
 SQL Update - Sending Null values

I am having trouble sending Null values thru SQL Update

I have tried everything including;

varB = TRIM(Request.form("varB"))

' text value passes properly

varA = Request.form("varA")

' value passes properly

if varA = "" Then
varA = Null
else
varA = CInt(varA)
end if

' value converts properly

SQL = "Update Table Set "
SQL = SQL & "varB= '" & varB & "', "
SQL = SQL & "varA= " & varA
SQL = SQL & " WHERE Id=" & (Request.Form("Recid"))

Conn.Execute(SQL)

If the Num Value varA = "any value" then all is fine,

If value becomes Null then error;

"Datatype mismatch in criteria expression"

ON THE Conn.Execute(SQL) LINE

But I need to send it to Access sometimes as a null value.

Using;
ADO

oRS.AddNew
varA = .....

oRS.Update

Works fine with Null value, but in SQL it Doesn't

Is there a way I can pass a null value thru SQL Update????

Thank you in advance

Matt



Thu, 18 Nov 2004 03:58:21 GMT  
 SQL Update - Sending Null values
Good morning from Seoul.

Compose sql with clear text /null/, ie,

conn.execute "update table1 set field1=null"

--
Han Pohwan
Seoul, Korea, MS Asia MVP

Quote:
> I am having trouble sending Null values thru SQL Update

> I have tried everything including;

> varB = TRIM(Request.form("varB"))

> ' text value passes properly

> varA = Request.form("varA")

> ' value passes properly

> if varA = "" Then
> varA = Null
> else
> varA = CInt(varA)
> end if

> ' value converts properly

> SQL = "Update Table Set "
> SQL = SQL & "varB= '" & varB & "', "
> SQL = SQL & "varA= " & varA
> SQL = SQL & " WHERE Id=" & (Request.Form("Recid"))

> Conn.Execute(SQL)

> If the Num Value varA = "any value" then all is fine,

> If value becomes Null then error;

> "Datatype mismatch in criteria expression"

> ON THE Conn.Execute(SQL) LINE

> But I need to send it to Access sometimes as a null value.

> Using;
> ADO

> oRS.AddNew
> varA = .....

> oRS.Update

> Works fine with Null value, but in SQL it Doesn't

> Is there a way I can pass a null value thru SQL Update????

> Thank you in advance

> Matt



Thu, 18 Nov 2004 11:44:10 GMT  
 SQL Update - Sending Null values
Thank you for reply -

So your saying, to check if any values are null and if
so, then conn.execute "update table set field(s)...=null"

it sounds good.

problem is that I have 5 of 25 pages with 20 or more
values to check.

would I be doing 20 checks and 20 conn.executes??
NO

sounds like array might work better??

maybe I'll make the users delete and add new record!

OK - can I conn.execute "table set 'all value fields to
null (fields 1-20), then load in # values on top"

ie
conn.exe"table set fields 1-20=null"

Then run Sql load

and then conn.execute(Sql)

Thank you again

Quote:
>-----Original Message-----
>Good morning from Seoul.

>Compose sql with clear text /null/, ie,

>conn.execute "update table1 set field1=null"

>--
>Han Pohwan
>Seoul, Korea, MS Asia MVP


>> I am having trouble sending Null values thru SQL Update

>> I have tried everything including;

>> varB = TRIM(Request.form("varB"))

>> ' text value passes properly

>> varA = Request.form("varA")

>> ' value passes properly

>> if varA = "" Then
>> varA = Null
>> else
>> varA = CInt(varA)
>> end if

>> ' value converts properly

>> SQL = "Update Table Set "
>> SQL = SQL & "varB= '" & varB & "', "
>> SQL = SQL & "varA= " & varA
>> SQL = SQL & " WHERE Id=" & (Request.Form("Recid"))

>> Conn.Execute(SQL)

>> If the Num Value varA = "any value" then all is fine,

>> If value becomes Null then error;

>> "Datatype mismatch in criteria expression"

>> ON THE Conn.Execute(SQL) LINE

>> But I need to send it to Access sometimes as a null
value.

>> Using;
>> ADO

>> oRS.AddNew
>> varA = .....

>> oRS.Update

>> Works fine with Null value, but in SQL it Doesn't

>> Is there a way I can pass a null value thru SQL
Update????

>> Thank you in advance

>> Matt

>.



Thu, 18 Nov 2004 12:41:40 GMT  
 SQL Update - Sending Null values
I fixed it

I am using

if NOT(A = "") Then
varA = Request.form("A")
else
varA = Null
end if

rs.fields("A") = varA

rs.update
rs.close
...etc

Thank you for the Help

Quote:
>-----Original Message-----
>Thank you for reply -

>So your saying, to check if any values are null and if
>so, then conn.execute "update table set field(s)...=null"

>it sounds good.

>problem is that I have 5 of 25 pages with 20 or more
>values to check.

>would I be doing 20 checks and 20 conn.executes??
>NO

>sounds like array might work better??

>maybe I'll make the users delete and add new record!

>OK - can I conn.execute "table set 'all value fields to
>null (fields 1-20), then load in # values on top"

>ie
>conn.exe"table set fields 1-20=null"

>Then run Sql load

>and then conn.execute(Sql)

>Thank you again

>>-----Original Message-----
>>Good morning from Seoul.

>>Compose sql with clear text /null/, ie,

>>conn.execute "update table1 set field1=null"

>>--
>>Han Pohwan
>>Seoul, Korea, MS Asia MVP


>>> I am having trouble sending Null values thru SQL
Update

>>> I have tried everything including;

>>> varB = TRIM(Request.form("varB"))

>>> ' text value passes properly

>>> varA = Request.form("varA")

>>> ' value passes properly

>>> if varA = "" Then
>>> varA = Null
>>> else
>>> varA = CInt(varA)
>>> end if

>>> ' value converts properly

>>> SQL = "Update Table Set "
>>> SQL = SQL & "varB= '" & varB & "', "
>>> SQL = SQL & "varA= " & varA
>>> SQL = SQL & " WHERE Id=" & (Request.Form("Recid"))

>>> Conn.Execute(SQL)

>>> If the Num Value varA = "any value" then all is fine,

>>> If value becomes Null then error;

>>> "Datatype mismatch in criteria expression"

>>> ON THE Conn.Execute(SQL) LINE

>>> But I need to send it to Access sometimes as a null
>value.

>>> Using;
>>> ADO

>>> oRS.AddNew
>>> varA = .....

>>> oRS.Update

>>> Works fine with Null value, but in SQL it Doesn't

>>> Is there a way I can pass a null value thru SQL
>Update????

>>> Thank you in advance

>>> Matt

>>.

>.



Thu, 18 Nov 2004 13:18:29 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Sending null strings and NULL values

2. SQL Update Statement with NULL

3. Send a <NULL> value

4. Update a DATE-field to a NULL-value

5. update Null values

6. Update integer field with "Null" value

7. SQL Error writing null value field

8. dealing with NULL values in a SQL Table.

9. Help! Sending Nulls to MS SQL

10. Populating Null value in SQL Date/Time field

11. NULL Values in SQL Queries - HELP!

12. Sql Update query syntax to increment a column containing nulls

 

 
Powered by phpBB® Forum Software