473,394 Members | 1,671 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,394 software developers and data experts.

Column contains NULL data

dr.GetString(2) is Null how do I deal with that?

Line 72: Do While dr.Read
Line 73: aString = aString + CStr(dr.GetValue(0)) + ":" &
dr.GetString(1) + ":" & dr.GetString(2) + ":" + dr.GetString(3) + ":"
Line 74: Loop

--
David
Nov 18 '05 #1
4 6208
if(dr.GetValue(0) != null)
....
else
.....
--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"DaveF" <df*****@geodecisions.com> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
dr.GetString(2) is Null how do I deal with that?

Line 72: Do While dr.Read
Line 73: aString = aString + CStr(dr.GetValue(0)) + ":" &
dr.GetString(1) + ":" & dr.GetString(2) + ":" + dr.GetString(3) + ":"
Line 74: Loop

--
David

Nov 18 '05 #2
Dave,

If Not dr.GetString(2) Is System.DBNull.Value Then

End If

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"DaveF" <df*****@geodecisions.com> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
dr.GetString(2) is Null how do I deal with that?

Line 72: Do While dr.Read
Line 73: aString = aString + CStr(dr.GetValue(0)) + ":" &
dr.GetString(1) + ":" & dr.GetString(2) + ":" + dr.GetString(3) + ":"
Line 74: Loop

--
David

Nov 18 '05 #3
On Mon, 14 Jun 2004 15:25:48 -0400, DaveF <df*****@geodecisions.com> wrote:
dr.GetString(2) is Null how do I deal with that?

Line 72: Do While dr.Read
Line 73: aString = aString + CStr(dr.GetValue(0)) + ":" &
dr.GetString(1) + ":" & dr.GetString(2) + ":" + dr.GetString(3) + ":"
Line 74: Loop


You have to manually check the case that it is DbNull.Value. I usually
create a StringUtil class w/ static methods that do stuff like this ()

Public Static Function StringUtil.ToString(val as object) as string
if ((val = DbNull.value) orelse (val = null)) Then
return String.empty
else
return val.ToString()
end if
end function

sorry, haven't done vb.net in awhile, so use as a guideline...

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 18 '05 #4
Or you could just do a ToString on it....Intellisense won't work but
it will convert DBnull values to "".

On Mon, 14 Jun 2004 15:04:26 -0500, "Craig Deelsnyder"
<cdeelsny@no_spam_4_meyahoo.com> wrote:
On Mon, 14 Jun 2004 15:25:48 -0400, DaveF <df*****@geodecisions.com> wrote:
dr.GetString(2) is Null how do I deal with that?

Line 72: Do While dr.Read
Line 73: aString = aString + CStr(dr.GetValue(0)) + ":" &
dr.GetString(1) + ":" & dr.GetString(2) + ":" + dr.GetString(3) + ":"
Line 74: Loop


You have to manually check the case that it is DbNull.Value. I usually
create a StringUtil class w/ static methods that do stuff like this ()

Public Static Function StringUtil.ToString(val as object) as string
if ((val = DbNull.value) orelse (val = null)) Then
return String.empty
else
return val.ToString()
end if
end function

sorry, haven't done vb.net in awhile, so use as a guideline...


Nov 18 '05 #5

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

Similar topics

4
by: R. Santiago | last post by:
I have a table cc_rd_user_questions with the following columns: NUM NUMBER (25) DEFAULT 1 NOT NULL, COMPANY_ID NUMBER (15) NOT NULL, PROJ_ID NUMBER (15) NOT NULL, SEQ ...
0
by: Marc Floessel | last post by:
Considering the following example table: Column1 | Column2 | Column3 =========================== NULL |"Value1" | NULL --------------------------- "Value2"| NULL | NULL...
1
by: Danny | last post by:
I'm trying to simply change a column definition from Null to Not Null. It's a multi million row table. I've already checked to make sure there are no nulls for any rows and a default has been...
1
by: p175 | last post by:
People, I have the following table and I need to add a column that uses a the listed UDF to count the number of days within specific quarters by year. CREATE TABLE HISTORY_MB (...
3
by: Bill C. | last post by:
Hello, I know this has been discussed a lot already because I've been searching around for information the last few weeks. I'm trying to implement a DataGridComboBoxColumn class. I've found...
4
by: Brian Brane | last post by:
I have properties that wrap DataRow columns as in: public int aNumber { get{ return m_DataRow; } set{ m_DataRow = value; } } If the column happens to contain DBNull, I get a cast exception...
1
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
1
by: Frank Swarbrick | last post by:
We're trying to take advantage of the new ROW CHANGE TIMESTAMP option. Here is a simple table: CREATE TABLE "ACCTASGN"."NUMBER_STATUS" ( "STATUS_CODE" CHAR(1) NOT NULL , "STATUS_DESCRIPTION"...
6
by: =?iso-8859-2?Q?Marcin_Dzi=F3bek?= | last post by:
Hi All: I need to get (filter in) some dataview's rows with DBNULLs in column of boolean type: Actually to get the only rows with DBNULL, I use code like this: DV.RowFilter =...
0
by: priyamtheone | last post by:
I'm trying to make a datagridview column to act like a datetimepicker column (C#.Net 2005). These are the behaviours that the dgv should have: 1) Initially all the cells of the dtp column should be...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.