473,382 Members | 1,247 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

problem with null data in sql

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
Nov 18 '05 #1
4 1244
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" <lu**@themoon.com> wrote in message
news:Ap***************@newsfep3-gui.server.ntli.net...
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

Nov 18 '05 #2
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" <lu**@themoon.com> 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


Nov 18 '05 #3
that did the trick thanks!!

mark
"Janaka" <ja****@magicalia.com> wrote in message
news:Oc**************@TK2MSFTNGP11.phx.gbl...
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" <lu**@themoon.com> wrote in message
news:Ap***************@newsfep3-gui.server.ntli.net...
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


Nov 18 '05 #4
yes no entry in the database

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

thanks

mark

"Dan Brussee" <db******@nc.rr.com> wrote in message
news:om********************************@4ax.com...
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" <lu**@themoon.com> 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 thereisnt a problem

Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dani | last post by:
Hi everyone Description of the problem: Using a PreparedStatement to write down an integer (int) plus a timestamp for testing purposes. When read out again the integer looks very different. We...
57
by: Xarky | last post by:
Hi, I am writing a linked list in the following way. struct list { struct list *next; char *mybuff; };
7
by: Auto | last post by:
I starting to use Visual Studio .NET 2003 creating C# Windows application with SQL Server and I get problem with method Fill() for which when running ends with System Error even with the most...
2
by: ddaniel | last post by:
I have read many posts and seen many papers on the different techniques for sort and filtering datagrids. Many do re-queries against the dB ala Fritz Onion. I am trying to leverage the Dataview....
30
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a...
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
2
by: mob1012 via DBMonster.com | last post by:
Hi All, I wrote last week about a trigger problem I was having. I want a trigger to produce a unique id to be used as a primary key for my table. I used the advice I received, but the trigger is...
4
by: nishi57 | last post by:
I hope I can get some help regarding this issue, which has been going on for a while. I have a desktop user who is having problem running "Stored Procedures". The DB2 Connect application works fine...
3
by: iskeletor | last post by:
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> #define STUDENT_NUMBER 68 #define ARRAY_LENGTH 10 struct node{ char Name,Surname; int data,no;
5
by: Chad | last post by:
say my input file is $ more suck ______ < gnu? > ------ \ , , \ /( )` \ \ \___ / | /- _ `-/ '
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.