|
-
May 27th, 2003, 11:41 AM
#1
Thread Starter
Junior Member
quick question on UPDATE query
If i want to set a text value in the database to null how should I pass that in the UPDATE Statement ?
I tried these and didn't work --
Update val = ' '
Update val = NULL
Update val as NULL
Update val = "' '"
This has been bugging me for the past few minutes so I appreciate if any one can show me the way. Thanks
-
May 27th, 2003, 11:45 AM
#2
Frenzied Member
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
May 27th, 2003, 11:58 AM
#3
Thread Starter
Junior Member
DOES'T seem to work...
Is this how to do it ?
set DBNull.columnName
-
May 27th, 2003, 12:02 PM
#4
-
May 27th, 2003, 12:10 PM
#5
Thread Starter
Junior Member
Nope...IS NULL doesn't work either
I guess I will use
Set Val = ' '
then trim the space out when I load the table values into my program.
Thanks
-
May 27th, 2003, 12:13 PM
#6
Frenzied Member
here's my Update query...txtVendor.Text can have a NULL and it gets updated fine.
VB Code:
sqlcmd = "update pcms.pcms_pcard_transaction_header set vendor_name=?, transaction_amt=?, sales_tax_amt=?, updated_by=?,updated_date=? where trans_seq_no=" & sFirstCell
Dim objCommand As New OleDbCommand(sqlcmd, objCon)
objCommand.Parameters.Add("@vendor_name", System.Data.OleDb.OleDbType.Char, 42).Value = txtVendor.Text
then when I go to populate my textboxes on my form, I do a NULL check...
VB Code:
If (objDR("vendor_name")) Is DBNull.Value Then
txtVendor.Text = String.Empty
Else : txtVendor.Text = (objDR("vendor_name"))
End If
HTH....
It's tough being an unhandled exception...
___________
VB.NET 2008
VB.NET 2010
ORACLE 11g
CRYSTAL 11
-
May 27th, 2003, 12:19 PM
#7
Addicted Member
You could put in a Chr(0) as the value. Chr(0) returns a null equivelant.
-
May 27th, 2003, 04:14 PM
#8
Member
isn't it
myparam=nothing
thats what I use
tal
its called the "F1" key-- use it
-
May 28th, 2003, 03:24 AM
#9
Sleep mode
Originally posted by vujjeni
DOES'T seem to work...
Is this how to do it ?
set DBNull.columnName
Set keyword is no longer used in VB.NET . A workaround is to set the field in the database itself to accept null values . This works well all the time .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|