469,575 Members | 1,658 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,575 developers. It's quick & easy.

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 1574
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by djc | last post: by
3 posts views Thread by Joćo Roberto Alonso | last post: by
6 posts views Thread by tshad | last post: by
reply views Thread by Elmo Watson | last post: by
9 posts views Thread by Robert Bravery | last post: by
5 posts views Thread by Leon Mayne | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.