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

converting to dbnull

I have instantiated an insertRow for a dataset. I now want to make the
GLCode DBNull.

I have tried:
insertRow.GLCode = Convert.dbnull
insertRow.GLCode = Convert.dbnull(insertRow.GLCode)

and several other things.

How is it done?
Nov 19 '05 #1
4 1703
JV
insertRow.GLCode = System.DBNull.Value;

"Tina" <ti**********@removespamexcite.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I have instantiated an insertRow for a dataset. I now want to make the
GLCode DBNull.

I have tried:
insertRow.GLCode = Convert.dbnull
insertRow.GLCode = Convert.dbnull(insertRow.GLCode)

and several other things.

How is it done?

Nov 19 '05 #2
I tried that too: Value of type "System.dbnull" cannot be converted to
'String'
is the compile error.
T

"JV" <jo**********@goisc.com> wrote in message
news:e3**************@TK2MSFTNGP15.phx.gbl...
insertRow.GLCode = System.DBNull.Value;

"Tina" <ti**********@removespamexcite.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I have instantiated an insertRow for a dataset. I now want to make the
GLCode DBNull.

I have tried:
insertRow.GLCode = Convert.dbnull
insertRow.GLCode = Convert.dbnull(insertRow.GLCode)

and several other things.

How is it done?


Nov 19 '05 #3
JV
Oh, I'm sorry. I didn't think long enough about what you wrote.

You are working with a typed dataset, so there is some "automagic" code
generation done for you to allow those columns to be strongly typed. That
works great when the columns aren't nullable. Unfortunately, they don't
deal well with DBNull values. Annoying, huh?

You can do this instead:

insertRow["GLCode"] = System.DBNull.Value;

Thus, you are using the string-based array indexer to get a reference to
the column in question. This is a feature of the DataRow class which is a
base class of your row's class, so this capability is inherited. It's
perfectly happy with DBNull.Value.

Cheers!

--JV
"Tina" <ti**********@removespamexcite.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I tried that too: Value of type "System.dbnull" cannot be converted to
'String'
is the compile error.
T

"JV" <jo**********@goisc.com> wrote in message
news:e3**************@TK2MSFTNGP15.phx.gbl...
insertRow.GLCode = System.DBNull.Value;

"Tina" <ti**********@removespamexcite.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I have instantiated an insertRow for a dataset. I now want to make the
GLCode DBNull.

I have tried:
insertRow.GLCode = Convert.dbnull
insertRow.GLCode = Convert.dbnull(insertRow.GLCode)

and several other things.

How is it done?



Nov 19 '05 #4
Yes, that worked just fine. Interesting issue.
Thanks,
T

"JV" <jo**********@goisc.com> wrote in message
news:uh**************@TK2MSFTNGP10.phx.gbl...
Oh, I'm sorry. I didn't think long enough about what you wrote.

You are working with a typed dataset, so there is some "automagic" code
generation done for you to allow those columns to be strongly typed. That
works great when the columns aren't nullable. Unfortunately, they don't
deal well with DBNull values. Annoying, huh?

You can do this instead:

insertRow["GLCode"] = System.DBNull.Value;

Thus, you are using the string-based array indexer to get a reference to
the column in question. This is a feature of the DataRow class which is a
base class of your row's class, so this capability is inherited. It's
perfectly happy with DBNull.Value.

Cheers!

--JV
"Tina" <ti**********@removespamexcite.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I tried that too: Value of type "System.dbnull" cannot be converted to
'String'
is the compile error.
T

"JV" <jo**********@goisc.com> wrote in message
news:e3**************@TK2MSFTNGP15.phx.gbl...
insertRow.GLCode = System.DBNull.Value;

"Tina" <ti**********@removespamexcite.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I have instantiated an insertRow for a dataset. I now want to make the
GLCode DBNull.

I have tried:
insertRow.GLCode = Convert.dbnull
insertRow.GLCode = Convert.dbnull(insertRow.GLCode)

and several other things.

How is it done?



Nov 19 '05 #5

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

Similar topics

3
by: Dave Byron | last post by:
I am having trouble with DBNull's from my SQL server. I am building/converting a asset web app from Access and my db has nulls on various fields . I have tried searching newsgroups and tried to get...
7
by: djc | last post by:
I have typically always used one of the VB CType functions (not CType itself but CInt, CString, etc...) to cast/convert an input value to its proper type before passing it as a parameter to a SQL...
3
by: Joćo Roberto Alonso | last post by:
Hi I wanto to know if there is a way to convert a DBNull.Value to Decimal and returns to me Decimal.Zero? Examples COLUMN1 = NULL from DB Ex1.: cstr((dt.rows(0).item("COLUMN1"))
6
by: tshad | last post by:
I have a value coming from my Object (or it could also be from a SqlDbReader) where I need to test for DBNull and 0. I tried to do it in one call: if (not (newPosition.ReportsTo is...
0
by: Elmo Watson | last post by:
I am having all kinds of problems with a Stored Proc I'm trying to run, with the error I'm getting above. First - the way I'm reading it - the database EXPECTS a TinyInt - and it thinks I'm...
19
by: Dave | last post by:
If Iwant to check if dataset1.SelectQuery1.column1 == System.DBNull.Value. How do I do this? What I wrote above will give an error. -- L. A. Jones
9
by: Robert Bravery | last post by:
HI all, I have a column value returned to a string variable in my c# app. But the return type is of system.dbnull. How can I convert that to a system.sting Thanks Robert
1
by: Brad Pears | last post by:
I am using vb.net 2005 and SQL server 2000. In my table I have a date field of type "smalldatetime". In my vb application, the user may or may not enter a date value into the appropriate text box....
5
by: Leon Mayne | last post by:
We currently have lots of checks in our businesslayer object's Load() functions that look like: If drCourse("txtTTMCnotes").Equals(DBNull.Value) Then Me._txtTTMCnotes = "" Else...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.