473,320 Members | 2,189 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,320 software developers and data experts.

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

reply to: be***@pocketrocks.com 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" msdata:DeleteRule="Cascade" msdata:UpdateRule="Cascade">
<xs:selector xpath=".//mstns:Tree" />
<xs:field xpath="mstns:AttributeID" />
</xs:keyref>
<xs:keyref name="TreeTree" refer="TreeIDKey" msdata:DeleteRule="Cascade" msdata:UpdateRule="Cascade">
<xs:selector xpath=".//mstns:Tree" />
<xs:field xpath="mstns:ChildOf" />
</xs:keyref>
</xs:element>
</xs:schema>
Nov 21 '05 #1
0 1693

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

Similar topics

26
by: Agoston Bejo | last post by:
I want to enforce such a constraint on a column that would ensure that the values be all unique, but this wouldn't apply to NULL values. (I.e. there may be more than one NULL value in the column.)...
3
by: A.M. de Jong | last post by:
Reading a lot about Nulls right now I still can't find a Technical reason to use it or not. For what I've understand is this: In an Ingres database a Null column has a standard extra storage...
6
by: Kevin Frey | last post by:
Hello, I have a table which contains some nullable columns. I want to write a single query, which can be prepared (ie. prepared statement), that can handle null or non-null values for the where...
3
by: iStrain | last post by:
Hiya. I'm _sure_ this is an FAQ, but Googling hasn't produced the answer in a way I can make sense out of. I know I should get this, but so far no way... I'm creating tables and doing queries in...
3
by: google | last post by:
This is something I've done plenty of times in '97, but I can't seem to get it to work correctly in Access 2003. Say, for example, I have a form with an unbound combobox, the data source is a...
53
by: Zhiqiang Ye | last post by:
Hi, All I am reading FAQ of this group. I have a question about this: http://www.eskimo.com/~scs/C-faq/q7.31.html It says: " p = malloc(m * n); memset(p, 0, m * n); The zero fill is...
102
by: junky_fellow | last post by:
Can 0x0 be a valid virtual address in the address space of an application ? If it is valid, then the location pointed by a NULL pointer is also valid and application should not receive "SIGSEGV"...
3
by: binder | last post by:
I am designing a new table with a few columns that may or may not have a value on each row that is inserted. What issues determine whether to allow a NULL value to be inserted for that column or...
4
by: Eric Layman | last post by:
Hi everyone, Im puzzled by a NULL behaviour in SQL 2000 server. There is a column in the table that does not allow NULL. During data mining, the staff noted that, for that particular column,...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.