Teemu Keiski
6/17/2009 10:54:00 AM
On 31 touko, 19:23, John <J...@discussions.microsoft.com> wrote:
> Hi all:
>
> I need to read an access database from a C# program and then create records
> in MSCRM from the Access data. However I have run into a snag with blank data
> values in the Access table which I cannot seem to detect. I am reading the
> table thus:
>
> myOleDbCommand.CommandText = "SELECT * FROM tblAgentInfo";
> while (myOleDbDataReader.Read() && iCount <5)
> {
> if (myOleDbDataReader["BrokerID"] != DBNull.Value)
> {
> string name = myOleDbDataReader["BrokerID"].ToString();
> }
>
> }
>
> However I am not catching blank values in the if statement. I have also tried:
> myOleDbDataReader["BrokerID"] != null
> myOleDbDataReader["BrokerID"] != ""
> myOleDbDataReader["BrokerID"] != " "
>
> But none of these have worked.
>
> Can anyone make a suggestion?
>
> Thanks.
>
> John.
Hi,
you should ask this at adonet group but point is that the null in
database maps to DBNull type in .NEt Framework. And to check for nulls
you can use Convert.IsDBNull function
Teemu Keiski
ASP.NET MVP