Assign the null value to DB2 fields. 
Author Message
 Assign the null value to DB2 fields.

Hi, I am using the ODBC to connect to DB2 database, and I
would like to write new records to my table. I need to
assign the null value to some fields. I tried to use the
following code:
        My_DB2_Field = Nothing
,but VB assign the 0 to My_DB2_Field. Can anyone help me
with this?(some sample code will be great) Thanks!


Sat, 13 Nov 2004 21:55:19 GMT  
 Assign the null value to DB2 fields.
Hi John,

Have you tried :
    My_DB2_Field = System.DBNull.Value


Quote:
> Hi, I am using the ODBC to connect to DB2 database, and I
> would like to write new records to my table. I need to
> assign the null value to some fields. I tried to use the
> following code:
>         My_DB2_Field = Nothing
> ,but VB assign the 0 to My_DB2_Field. Can anyone help me
> with this?(some sample code will be great) Thanks!



Sat, 13 Nov 2004 22:24:41 GMT  
 Assign the null value to DB2 fields.
Yes, I did.
but, I got a error "Value of type 'System.DBNull' cannot
be converted to 'integer'".

Quote:
>-----Original Message-----
>Hi John,

>Have you tried :
>    My_DB2_Field = System.DBNull.Value



>> Hi, I am using the ODBC to connect to DB2 database, and
I
>> would like to write new records to my table. I need to
>> assign the null value to some fields. I tried to use the
>> following code:
>>         My_DB2_Field = Nothing
>> ,but VB assign the 0 to My_DB2_Field. Can anyone help me
>> with this?(some sample code will be great) Thanks!

>.



Sun, 14 Nov 2004 01:27:00 GMT  
 Assign the null value to DB2 fields.
Hi John,

Ah, okay, sounds like you are referencing the field via a strongly typed dataset.
If that is the case, you can have a SetXXXToNull method that set's the underlying
value to dbNull.Value.  You basically have to bypass the strongly typed interface
you have because Integers always have a value.


Quote:
> Yes, I did.
> but, I got a error "Value of type 'System.DBNull' cannot
> be converted to 'integer'".

> >-----Original Message-----
> >Hi John,

> >Have you tried :
> >    My_DB2_Field = System.DBNull.Value



> >> Hi, I am using the ODBC to connect to DB2 database, and
> I
> >> would like to write new records to my table. I need to
> >> assign the null value to some fields. I tried to use the
> >> following code:
> >>         My_DB2_Field = Nothing
> >> ,but VB assign the 0 to My_DB2_Field. Can anyone help me
> >> with this?(some sample code will be great) Thanks!

> >.



Sun, 14 Nov 2004 05:00:06 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Assigning Null Values to data bound fields using remote data control

2. Assigning a Date field a Null value....

3. Assigning Null value to field of ADO Recordset

4. Assigning a Date field a Null value....

5. adodb connection to excel: recordset.fields(i).value=null for fields with numeric value

6. adodb connection to excel: recordset.fields(i).value=null for fields with numeric value

7. adodb connection to excel: recordset.fields(i).value=null for fields with numeric value

8. DB2 Null value problem

9. doesn't recognize Null value from a field value

10. ASSIGN STRING NULL VALUE?

11. CAN'T ASSIGN A NULL VALUE TO A VARIABLE

12. How to assign a null-value to a int32

 

 
Powered by phpBB® Forum Software