Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6652251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:06:48+00:00 2026-05-26T01:06:48+00:00

I am connecting to a MS-Access 2007 database using VB 2010 and OLEDB. Conducting

  • 0

I am connecting to a MS-Access 2007 database using VB 2010 and OLEDB. Conducting the following test seems to suggest that MS-Access does not interpret DBNull.Value correctly when sent as a parameter from OLEDB:

(The Hospital table contains 1 row with the “LatLong” column set to null)

Dim cnt = Common.GetScalar(axsCon, "SELECT Count(*) FROM Hospitals WHERE LatLong = @LL ", _
                New String() {"LL"},
                New Object() {DBNull.Value})

This query returns cnt = 0

However:
cnt = Common.GetScalar(axsCon, “SELECT Count(*) FROM Hospitals WHERE LatLong IS NULL “)

returns cnt = 1

Any ideas are appreciated.

p.s.:
Common.GetScalar looks like:

Public Shared Function GetScalar( _
    ByRef OleCon As OleDbConnection, _
    ByRef SQL As String, _
    Optional ByRef Params() As String = Nothing, _
    Optional ByRef Vals() As Object = Nothing, _
    Optional IsQuery As Boolean = False) As Object
    Try
        Dim oleCmd As OleDbCommand = OleCon.CreateCommand
        oleCmd.CommandType = IIf(IsQuery, CommandType.StoredProcedure, CommandType.Text)
        oleCmd.CommandText = SQL
        If Not Params Is Nothing Then
            Dim pInx As Int16
            For pInx = 0 To Params.Count - 1
                oleCmd.Parameters.AddWithValue(Params(pInx), Vals(pInx))
            Next
        End If
        Return oleCmd.ExecuteScalar()
    Catch ex As Exception
        Throw New Exception(ex.Message)
    End Try
End Function

TIA

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:06:48+00:00Added an answer on May 26, 2026 at 1:06 am

    Change

    "SELECT Count(*) FROM Hospitals WHERE LatLong = @LL"
    

    to

    “SELECT Count(*)
    FROM Hospitals
    WHERE 1=
        CASE
            WHEN @LL IS null AND LatLong IS null THEN 1
            WHEN LatLong = @LL THEN 1
        END”

    This will then check for null or matching value. Nulls can be very very tricky.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a front-end Access 2007 database connecting to MySql tables using MySQL ODBC
I'm using this connection string to access excel(2007,2010) files oleConnection.ConnectionString = @Provider=Microsoft.ACE.OLEDB.12.0;Data Source= +
ms-access is connecting to a local mysql database the following code returns an error:
I'm connecting the access 2007 database from 5 different machines. (C#.Net) I'm having this
I have a site that uses classic ASP and a database in Access 2007
I am new in creating application using Visual Studio 2010 and Microsoft Access 2007.
I'm using Access 2007 connecting to a MS SQL db through ODBC. I have
i connecting to a access database with php and adodb. Strings with characters like
access is connecting to a mysql database. the rowsource of one of a listbox
I've recently made another question about connecting to MS-ACCESS database with .NET in C#

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.