Earl wrote:
Hmmm, I can't check DbNull.Value of an object though. It has to be the value
of the object -- which it cannot be until I cast it. I can check the object
as to whether or not it is null. So my thinking is, well, ExecuteScalar only
returns one row, one column anyway (a single value) or else it returns null.
Is that the wrong way of looking at it?
The following primitive examples works for me:
using System;
using System.Data.OleDb;
public class MainClass
{
public static void Main(string[] args)
{
OleDbConnection con = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=C:\\Databases\\MSAccess\\Test.mdb");
con.Open();
OleDbCommand cmd1 = new OleDbCommand("SELECT NULL", con);
object v1 = cmd1.ExecuteScalar();
if(v1 == DBNull.Value)
{
Console.WriteLine("NULL");
}
OleDbCommand cmd2 = new OleDbCommand("SELECT * FROM t1 WHERE 1
2", con);
object v2 = cmd2.ExecuteScalar();
if(v2 == null)
{
Console.WriteLine("null");
}
}
}
Arne