PC Review


Reply
Thread Tools Rate Thread

How? Add a row will a null value in a column that requires a keyrefrence?

 
 
Benny Raymond
Guest
Posts: n/a
 
      20th Oct 2004
reply to: (E-Mail Removed) if possible:

I'm trying to set up a hierarchy system in this database where each row
can be related to a previous row. The problem is that when I go to
addTreeRow, it doesn't allow me to use Convert.DBNull for the childof
column, even though I have nilable set to true. (All parent nodes have
to be set to null, since they are not the child of any other row...
especially the very first row, which will have no other row to refer
to.) What is it I'm doing wrong... Does anyone know how to set up a
relationship between a row and one of it's table's earlier rows?

Something interesting to note, if I use a DataGrid, it works perfectly
fine. I just can't add rows using vb code - I can add as many rows with
a DataGrid as I want, and everything works perfectly. If I send it a
Nothing instead of Convert.DBNull, I get a better error (if you set it
up you'll see), it's an error in dataset1.vb, it looks like it's trying
to get an index from the value i'm sending - so it's crashing because it
can't get an index from a null value... Is there any possible way to get
around this? Is it a bug with the dataset compiler?

By the way, the reason I want to set this up is so that if I delete a
parent row, the cascade feature will delete all child rows, and so on.

attached is the VB.Net and XML Schema code i'm trying to use



vb code:
' crashes on this line if I use Convert.DBNull:
Dataset11.Tree.AddTreeRow("Title Test1", Convert.DBNull, Convert.DBNull)
Dataset11.Tree.AddTreeRow("Title Test2", Convert.DBNull, Convert.DBNull)
'Crashes in dataset1.vb if I use Nothing
Dataset11.Tree.AddTreeRow("Title Test3", Nothing, Nothing)


dataset code:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="Dataset1" targetNamespace="http://tempuri.org/Dataset1.xsd" elementFormDefault="qualified"
attributeFormDefault="qualified" xmlns="http://tempuri.org/Dataset1.xsd" xmlns:mstns="http://tempuri.org/Dataset1.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Dataset1" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Tree">
<xs:complexType>
<xs:sequence>
<xs:element name="TreeID" type="xs:integer" minOccurs="0" msdata:AutoIncrement="true" msdata:AutoIncrementStep="1"
msdata:AutoIncrementSeed="1" />
<xs:element name="Title" type="xs:string" minOccurs="0" />
<xs:element name="ChildOf" type="xs:integer" minOccurs="0" nillable="true" />
<xs:element name="AttributeID" type="xs:integer" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Attributes">
<xs:complexType>
<xs:sequence>
<xs:element name="AttributeID" type="xs:integer" minOccurs="0" msdata:AutoIncrement="true" msdata:AutoIncrementSeed="1"
msdata:AutoIncrementStep="1" />
<xs:element name="Title" type="xs:string" minOccurs="0" />
<xs:element name="Value" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="AttributeIDKey" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:Attributes" />
<xs:field xpath="mstns:AttributeID" />
</xs:key>
<xs:key name="TreeIDKey" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:Tree" />
<xs:field xpath="mstns:TreeID" />
</xs:key>
<xs:keyref name="AttributesTree" refer="AttributeIDKey" msdataeleteRule="Cascade" msdata:UpdateRule="Cascade">
<xs:selector xpath=".//mstns:Tree" />
<xs:field xpath="mstns:AttributeID" />
</xs:keyref>
<xs:keyref name="TreeTree" refer="TreeIDKey" msdataeleteRule="Cascade" msdata:UpdateRule="Cascade">
<xs:selector xpath=".//mstns:Tree" />
<xs:field xpath="mstns:ChildOf" />
</xs:keyref>
</xs:element>
</xs:schema>
 
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
Linq weirdness (improperly trying Column = Null instead of Column ISNULL) Andy Microsoft C# .NET 0 5th Mar 2008 04:11 PM
asp:menu requires Page.Header to be non-null michael Microsoft ASP .NET 2 14th Jan 2008 08:51 PM
Insert query with null column and null value =?Utf-8?B?RXVnZW5l?= Microsoft Access Queries 10 5th Oct 2007 03:41 AM
Add a new column to a table that requires a calculation. =?Utf-8?B?SnVzdGluODM3MTY=?= Microsoft Access Form Coding 2 8th Mar 2007 07:26 PM
Populating column N with a formula if column A is Null or Blank Steve Microsoft Excel Programming 4 28th Sep 2004 01:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:36 AM.