PC Review


Reply
Thread Tools Rate Thread

How do you set a value to Null in a DataSet when it's normally setto another table through a relation

 
 
Benny Raymond
Guest
Posts: n/a
 
      22nd Oct 2004
I currently have a relation set up between two tables in my dataset.
Sometimes I'd like to set the value in the Foreign Key Field to NULL (if
it doesn't refrence the other table at all).

Currently i'm getting an error no matter what I try to use:
0
Nothing
Convert.DBNull

Does anyone have experience in this area? I posted this question a few
days ago, but I didn't have as clear of an understanding as I do right
now. Currently I can set this field to Null using the data grid,
however I havn't been able to figure out how to add a row with this
field set to Null - it always gives an error

~Benny
 
Reply With Quote
 
 
 
 
W.G. Ryan eMVP
Guest
Posts: n/a
 
      22nd Oct 2004
If it doesn't reference the other table at all it's an Orphan which is what
the key there to prevent. You can try disabling the constraints but I
think that'd be a bad choice.

--
W.G. Ryan MVP (Windows Embedded)

TiBA Solutions
www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"Benny Raymond" <(E-Mail Removed)> wrote in message
news:aJXdd.20086$(E-Mail Removed)...
> I currently have a relation set up between two tables in my dataset.
> Sometimes I'd like to set the value in the Foreign Key Field to NULL (if
> it doesn't refrence the other table at all).
>
> Currently i'm getting an error no matter what I try to use:
> 0
> Nothing
> Convert.DBNull
>
> Does anyone have experience in this area? I posted this question a few
> days ago, but I didn't have as clear of an understanding as I do right
> now. Currently I can set this field to Null using the data grid,
> however I havn't been able to figure out how to add a row with this
> field set to Null - it always gives an error
>
> ~Benny



 
Reply With Quote
 
=?Utf-8?B?UnVsaW4gSG9uZw==?=
Guest
Posts: n/a
 
      22nd Oct 2004
use DBNull.Value Field

"Benny Raymond" wrote:

> I currently have a relation set up between two tables in my dataset.
> Sometimes I'd like to set the value in the Foreign Key Field to NULL (if
> it doesn't refrence the other table at all).
>
> Currently i'm getting an error no matter what I try to use:
> 0
> Nothing
> Convert.DBNull
>
> Does anyone have experience in this area? I posted this question a few
> days ago, but I didn't have as clear of an understanding as I do right
> now. Currently I can set this field to Null using the data grid,
> however I havn't been able to figure out how to add a row with this
> field set to Null - it always gives an error
>
> ~Benny
>

 
Reply With Quote
 
Benny Raymond
Guest
Posts: n/a
 
      22nd Oct 2004
That doesn't work, from that I get the error:
System.DBNull cannot be converted to WindowsApplication3.DataSet1.TreeRow

Rulin Hong wrote:
> use DBNull.Value Field
>
> "Benny Raymond" wrote:

 
Reply With Quote
 
Benny Raymond
Guest
Posts: n/a
 
      26th Oct 2004
Actually this morning I finally figured out how to do it. Instead of
using AddTreeRow("title",nothing,nothing) - which causes an error...
Instead I have to create a new row, set what I need to set, and then add
that row into the database like so:

Dim myrow As Dataset1.TreeRow = Dataset11.Tree.NewTreeRow
myrow.Title = "Title"
Dataset11.Tree.AddTreeRow(myrow)
Dataset11.Tree.Select()

It works perfectly and it's a lot easier to read than doing everything
in 1 large "AddTreeRow".

Hopefully someone else will find this useful as well.

~Benny
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Generated strongly typed dataset - null date column - exception when Fill or GetData called on table adaptor rharding@gmail.com Microsoft ADO .NET 3 1st Aug 2006 07:40 PM
DataSet 1 to many Relation - How to? =?Utf-8?B?U2hhcm9u?= Microsoft C# .NET 14 15th Jun 2005 08:01 AM
Filling a 2 table typed dataset with relation =?Utf-8?B?RGF2ZQ==?= Microsoft ADO .NET 4 11th Jun 2004 04:26 PM
avoiding Null Values in dataset.table and set them to empty string or 0 Anton Sommer Microsoft ADO .NET 5 27th Aug 2003 12:57 AM
Re: Dataset Relation Rebecca Riordan Microsoft ADO .NET 0 11th Jul 2003 03:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:01 PM.