Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Tring to not get and error when null is received from Recordset

Posted on 2004-11-02
Medium Priority
Last Modified: 2010-04-24
I have a record set that returns nulls in one of the fields.  The nulls are expected.  However I keep getting and error in the following code when a null is passed to the if then statement.  How do I keep for getting the null and choosing between the different types of greetings?


        emailSalutation = emailSalutation & "         <table width=600 border=1 cellpadding=10>" & vbCrLf
        emailSalutation = emailSalutation & "             <tr>" & vbCrLf
        emailSalutation = emailSalutation & "                 <td align='left'>" & vbCrLf
        If Len(rsEmailList("fldFirstName").Value) > 1 Then
            emailSalutation = emailSalutation & " <p>Dear " + rsEmailList("fldFirstName").Value + ",</p>"
            emailSalutation = emailSalutation & " <p>Dear Patron,</p>"
        End If
        emailSalutation = emailSalutation & "                 </td>" & vbCrLf
        emailSalutation = emailSalutation & "             </tr>" & vbCrLf
        emailSalutation = emailSalutation & "           </table>" & vbCrLf


thank you
Question by:Richard Comito
  • 2

Expert Comment

ID: 12477605
Hi Gabicus,

what is exactly the error message ?
If (Not rsEmailList("fldFirstName").IsNull) Then
      If Len(rsEmailList("fldFirstName").Value) > 1 Then ...

Hope this helps.

Accepted Solution

slyckboy earned 2000 total points
ID: 12477905
if not isdbnull( rsEmailList("fldFirstName")) then ...

this works with datatables/datasets, i assume it will treat recordsets the same, curious to know.

Author Comment

by:Richard Comito
ID: 12478130
Hi noulouk,

this is the error that I am getting:

An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll

Additional information: Type mismatch.

I tried what gave me but I get the error "isNull" is not a member of the ADODB.field


Author Comment

by:Richard Comito
ID: 12478206
Well slyckboy it works with recordset also.

Thank you

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses
Course of the Month11 days, 16 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question