Check for NULL field value without returning field value

Check for NULL field value without returning field value

Post by Steve Knot » Sat, 21 Dec 2002 00:24:27



I am struggling with an issue here using MSADO 2.7.

I am using this code in an IDE that does not have a nice "IsNull"  function
( I am using the ERP system Navision Attain 3.60 - if that makes sense to
anyone). Whenever I try and use the

Recordset.Fields("FieldName").Value

property, I get an error message, stating that the data type is not
supported (this only occurs should the field be <NULL> - I am reading out of
a MS-SQL 2000 db. I am returning the data into a variant type, but for some
reason this does not work.

Is there anyway to check for this before returning the field value.

In essence I am looking for a property or the like that allows me to skip
the offending field should it be NULL.  Is there some property I can set on
the connection to avoid this ? Or is it impossible to do ?

Thanks for any help / suggestions ?

Steve

 
 
 

Check for NULL field value without returning field value

Post by Val Mazu » Sat, 21 Dec 2002 00:31:40


Steve,

Did you try?

if IsNull(Recordset.Fields("FieldName").Value) then
.....
if it is not working, then I think something wrong with provider

--
Val Mazur
Microsoft MVP


Quote:> I am struggling with an issue here using MSADO 2.7.

> I am using this code in an IDE that does not have a nice "IsNull"
function
> ( I am using the ERP system Navision Attain 3.60 - if that makes sense to
> anyone). Whenever I try and use the

> Recordset.Fields("FieldName").Value

> property, I get an error message, stating that the data type is not
> supported (this only occurs should the field be <NULL> - I am reading out
of
> a MS-SQL 2000 db. I am returning the data into a variant type, but for
some
> reason this does not work.

> Is there anyway to check for this before returning the field value.

> In essence I am looking for a property or the like that allows me to skip
> the offending field should it be NULL.  Is there some property I can set
on
> the connection to avoid this ? Or is it impossible to do ?

> Thanks for any help / suggestions ?

> Steve


 
 
 

Check for NULL field value without returning field value

Post by Steve Knot » Sat, 21 Dec 2002 00:57:15


Unfortunatley , I do not have an IsNull function in Navision Attain 3.6, so
I can't use that code. I have used that method using ASP, VB etc, but I am
looking for a workaround, given that I don't have that function. I am
looking for a method or proprty within ADO 2.7 that could help.

Thanks
Steve


> Steve,

> Did you try?

> if IsNull(Recordset.Fields("FieldName").Value) then
> .....
> if it is not working, then I think something wrong with provider

> --
> Val Mazur
> Microsoft MVP



> > I am struggling with an issue here using MSADO 2.7.

> > I am using this code in an IDE that does not have a nice "IsNull"
> function
> > ( I am using the ERP system Navision Attain 3.60 - if that makes sense
to
> > anyone). Whenever I try and use the

> > Recordset.Fields("FieldName").Value

> > property, I get an error message, stating that the data type is not
> > supported (this only occurs should the field be <NULL> - I am reading
out
> of
> > a MS-SQL 2000 db. I am returning the data into a variant type, but for
> some
> > reason this does not work.

> > Is there anyway to check for this before returning the field value.

> > In essence I am looking for a property or the like that allows me to
skip
> > the offending field should it be NULL.  Is there some property I can set
> on
> > the connection to avoid this ? Or is it impossible to do ?

> > Thanks for any help / suggestions ?

> > Steve

 
 
 

Check for NULL field value without returning field value

Post by Roy Fin » Sat, 21 Dec 2002 08:18:26


Steve

I assume you code looks something like this:
/* ************************************* */
  _RecordsetPtr rset;
  ...
  _bstr_t myBstr;
  myBstr = rset->Fields->GetItem("FieldName").Value

/* ************************************* */

With that, you would get an exception thown on the null case.
my preference (using VC++) would be something like this:
/* ************************************* */
  _bstr_t myBstr;
  _variant_t myVar  = rset->GetCollect("FieldName")
  if(myVar.vt == VT_NULL) myBstr = L"";
  else
  myBstr = myVar.bstrVal;
/* ************************************* */

regards
roy fine


Quote:> I am struggling with an issue here using MSADO 2.7.

> I am using this code in an IDE that does not have a nice "IsNull"
function
> ( I am using the ERP system Navision Attain 3.60 - if that makes sense to
> anyone). Whenever I try and use the

> Recordset.Fields("FieldName").Value

> property, I get an error message, stating that the data type is not
> supported (this only occurs should the field be <NULL> - I am reading out
of
> a MS-SQL 2000 db. I am returning the data into a variant type, but for
some
> reason this does not work.

> Is there anyway to check for this before returning the field value.

> In essence I am looking for a property or the like that allows me to skip
> the offending field should it be NULL.  Is there some property I can set
on
> the connection to avoid this ? Or is it impossible to do ?

> Thanks for any help / suggestions ?

> Steve

 
 
 

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

Dear Guru's,

When I make an ADODBconnection to Excel files with Jet 3.51 and execute a
SQLquery statement to an ADODBrecordset I have the following issue:
If there are numeric values in general cellformat the
recordset.fields(i).value=null. If I make the cellformat=text then the
returned value's aren't NULL.
What is the problem? Should I change some recordset properties?
If yes: what, how?

2. DTS package

3. Checking for null values in a database field

4. send a message through network to a connected user

5. Checking for null value in an image field

6. Removing ODBC drivers from Windows 95

7. checking for null values in an iamge field

8. ?Alguien habla mi idioma?

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

10. Currency Fields Returning Null Values in DBGrid

11. Incrementing Next Field's Value Based Upon Prior Field's Value

12. HOWTO: Declare table field having Default Value - NULL or NOT NULL

13. NULL value in a NOT NULL field