Groups | Blog | Home
all groups > vb.net data > february 2004 >

vb.net data : Null values in ID field



Steve
2/23/2004 4:52:20 PM
Hiya

I have a strongly-typed DataSet that I am using in my form. The ID's for the
tables in the dataset are of an Int data type and are the Primary Keys. They
are automatically generated by the server when the record is saved. When I
add a new record to the dataset I get an error 'Column UserID does not allow
nulls'. In the xsd for the dataset I have looked at the column and it has a
check in the Nullable checkbox.

Is there a way to ignore the value of this field? It will always be null for
new records because the database inserts the correct value when saved.

Kind Regards,
Steve.

Paul Clement
2/24/2004 10:05:49 AM
[quoted text, click to view]

¤ Hiya
¤
¤ I have a strongly-typed DataSet that I am using in my form. The ID's for the
¤ tables in the dataset are of an Int data type and are the Primary Keys. They
¤ are automatically generated by the server when the record is saved. When I
¤ add a new record to the dataset I get an error 'Column UserID does not allow
¤ nulls'. In the xsd for the dataset I have looked at the column and it has a
¤ check in the Nullable checkbox.
¤
¤ Is there a way to ignore the value of this field? It will always be null for
¤ new records because the database inserts the correct value when saved.

If I had to take a guess I would say that allowing a null value for the UserID column is violating a
primary key constraint for the strongly-typed DataSet.


Paul ~~~ pclement@ameritech.net
Steve Amey
2/25/2004 7:15:40 PM
Hi Paul

Thanks for your response. Have you used or do you know any-one who uses
Strongly-typed datasets and how they avoided this problem? I made the
database field an IDENTITY type so I wouldn't have to worry about populating
the ID field with a value (amongst other things!).

Regards,
Steve.

[quoted text, click to view]

Paul Clement
2/27/2004 2:48:42 PM
[quoted text, click to view]

¤ Hi Paul
¤
¤ Thanks for your response. Have you used or do you know any-one who uses
¤ Strongly-typed datasets and how they avoided this problem? I made the
¤ database field an IDENTITY type so I wouldn't have to worry about populating
¤ the ID field with a value (amongst other things!).
¤

Since the value is auto generated anyway, can't you just plug a constant value in to work around the
xsd issue?


Paul ~~~ pclement@ameritech.net
Steve
3/1/2004 5:45:44 PM
Hi Paul

It has to be unique, and the user can enter many records, so I guess I'll
have to either have some global value that increments each time or determine
how to get a unique number for each addition

Thanks for your help.

Regards,
Steve.

[quoted text, click to view]

AddThis Social Bookmark Button