Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > problem with null data in sql

Reply
Thread Tools

problem with null data in sql

 
 
luna
Guest
Posts: n/a
 
      01-28-2004
could someone explain the meaning behind :- System.IndexOutOfRangeException:
firstname1

when the code is :-

If objDR("firstname1") Is System.DBNull.Value Then
firstname1.Text = ""
Else : firstname1.Text = objDR("fname1")
End If


and theres no entry in the database if theres an entry in the database there
isnt a problem


 
Reply With Quote
 
 
 
 
Janaka
Guest
Posts: n/a
 
      01-28-2004
luna,

I take it objDR is a DataReader? Try using its method of
objDR.IsDBNull() - you'll have to use the ordinal number of "firstname1"
instead.
So your code will look more like:

If objDR.IsDBNull(0) Then
....
End If

"luna" <(E-Mail Removed)> wrote in message
news:ApNRb.169$(E-Mail Removed)...
> could someone explain the meaning behind :-

System.IndexOutOfRangeException:
> firstname1
>
> when the code is :-
>
> If objDR("firstname1") Is System.DBNull.Value Then
> firstname1.Text = ""
> Else : firstname1.Text = objDR("fname1")
> End If
>
>
> and theres no entry in the database if theres an entry in the database

there
> isnt a problem
>
>



 
Reply With Quote
 
 
 
 
Dan Brussee
Guest
Posts: n/a
 
      01-28-2004
Your comment that there is no entry in the database makes me think
that the objDR is empty, so there is no current record. This is very
different than a field having a null value. Check if objDR is nothing
(or null depending on language flavor) before testing. You should
probably handle a null record differently than a null field value.

On Wed, 28 Jan 2004 11:54:51 -0000, "luna" <(E-Mail Removed)> wrote:

>could someone explain the meaning behind :- System.IndexOutOfRangeException:
>firstname1
>
>when the code is :-
>
>If objDR("firstname1") Is System.DBNull.Value Then
>firstname1.Text = ""
>Else : firstname1.Text = objDR("fname1")
>End If
>
>
>and theres no entry in the database if theres an entry in the database there
>isnt a problem
>


 
Reply With Quote
 
luna
Guest
Posts: n/a
 
      01-28-2004
that did the trick thanks!!

mark


"Janaka" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> luna,
>
> I take it objDR is a DataReader? Try using its method of
> objDR.IsDBNull() - you'll have to use the ordinal number of "firstname1"
> instead.
> So your code will look more like:
>
> If objDR.IsDBNull(0) Then
> ...
> End If
>
> "luna" <(E-Mail Removed)> wrote in message
> news:ApNRb.169$(E-Mail Removed)...
> > could someone explain the meaning behind :-

> System.IndexOutOfRangeException:
> > firstname1
> >
> > when the code is :-
> >
> > If objDR("firstname1") Is System.DBNull.Value Then
> > firstname1.Text = ""
> > Else : firstname1.Text = objDR("fname1")
> > End If
> >
> >
> > and theres no entry in the database if theres an entry in the database

> there
> > isnt a problem
> >
> >

>
>



 
Reply With Quote
 
luna
Guest
Posts: n/a
 
      01-28-2004
yes no entry in the database

If objDR.IsDBNull(1) Then
seems to do the trick

thanks

mark

"Dan Brussee" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> Your comment that there is no entry in the database makes me think
> that the objDR is empty, so there is no current record. This is very
> different than a field having a null value. Check if objDR is nothing
> (or null depending on language flavor) before testing. You should
> probably handle a null record differently than a null field value.
>
> On Wed, 28 Jan 2004 11:54:51 -0000, "luna" <(E-Mail Removed)> wrote:
>
> >could someone explain the meaning behind :-

System.IndexOutOfRangeException:
> >firstname1
> >
> >when the code is :-
> >
> >If objDR("firstname1") Is System.DBNull.Value Then
> >firstname1.Text = ""
> >Else : firstname1.Text = objDR("fname1")
> >End If
> >
> >
> >and theres no entry in the database if theres an entry in the database

there
> >isnt a problem
> >

>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Reference, SQL Queries, SQL help ecoolone ASP .Net 0 01-03-2008 10:58 AM
newbie: inserting data into sql form writes only null values thersitz ASP .Net 3 01-31-2007 11:58 PM
"stringObj == null" vs "stringObj.equals(null)", for null check?? qazmlp1209@rediffmail.com Java 5 03-29-2006 10:37 PM
VB.NET Null to SQL Null (ASP.NET 2.0 GridView) Kivak Wolf ASP .Net 2 06-28-2005 02:01 PM
Tools to extract data from SQL database and convert it into XML & insert XML data into SQL databases Harry Zoroc XML 1 07-12-2004 10:10 PM



Advertisments