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

allow nulls in strongly typed data set asp.net

I'm trying to use a strongly typed dataset in my asp.net (2.0) project with
visual studio 2005. I have generated the dataset and tableadapters in the
designer. I'm using SQL server EE 2005 as the database.

One of my tables has a guid field that has the "allow NULL" property in the
database. If I create a <typed>datatable, then try to add a row to the new
table, passing the value DBNULL.value as the field value in question, then I
get the exception System.Data.StrongTypingException("The value for column ...
is DBNULL.

If I go back and look at the generated code, it looks like the designer
generates code to throw these exceptions for those fields with "allow NULL",
and not for those that don't allow NULL. Isn't this exactly backwards?

More concretely: I have a field picture_id of type guid which, in the
database, allows NULL values.

if I look at the xml that's generated by the dataset designer, that
particular field looks like this:

<Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName=""
DbType="Guid" Direction="Input" ParameterName="@picture_id" Precision="0"
ProviderType="UniqueIdentifier" Scale="0" Size="0" SourceColumn="picture_id"
SourceColumnNullMapping="False" SourceVersion="Current"> </Parameter>

All looks fine so far, but if I then look at the actual VB generated by VS
2005, it looks like this:

Public Property picture_id() As System.Guid
Get
Try
Return
CType(Me(Me.tablepeople.picture_idColumn),System.G uid)
Catch e As System.InvalidCastException
Throw New System.Data.StrongTypingException("The value
for column 'picture_id' in table 'people' is DBNull.", e)
End Try
End Get
Set
Me(Me.tablepeople.picture_idColumn) = value
End Set
End Property

Which, again, seems EXACTLY BACKWARDS???? Shouldn't "allow NULL" mean
"handle NULL gracefully"? And "don't allow NULL" mean "generate a
catastrophic error (i.e., throw an exception) if NULL occurs"???

Just for reference, other fields that don't have "allow NULL" checked don't
have the code to generate the exception...

Any ideas? Am I suffering from a cranial inversion of some kind?
Jun 14 '06 #1
0 1814

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

Similar topics

3
by: Trevor Best | last post by:
Is there a *simple* way to change a collumn from allowing null to not null? I just unchecked "allow nulls" in EM and the SQL it generates to do this one thing is astonishing, create table, drop...
2
by: Mark | last post by:
Just wanted to confirm that my understanding of a strongly typed language is correct: 1. .NET is a strongly typed language because each variable / field must be declared a specific type (String,...
4
by: Mark | last post by:
We have a SQL Server table with a decimal column that is not required. We're building a .NET application for data entry. If the value is optional, but a decimal is strongly typed in C# and cannot...
2
by: David | last post by:
I have been developing applications with Java for quite a while but I am new to .NET development. I am trying to learn the ".NET way" of creating Strongly Typed Objects from a database. The...
1
by: HardBap | last post by:
I've created a strongly typed DataSet (Customers.xsd) using the xsd.exe tool. I want to be able to access fields using ds.Customer.CompanyName. The problem is when I return this DataSet from a...
1
by: PeterH | last post by:
I am developing a web service in VB.Net that returns data from a server. I have an .asmx page that uses a strongly typed dataset and I would like to return data in the form of strongly typed data...
5
by: John | last post by:
Hi I have a vb.net winform data app with sql server 2005 backend. The ID field in the tblClients table is an 'int' identity column that does not allow nulls. The problem is that when I try to...
1
by: Code Monkey | last post by:
Silly question maybe, but I've been doing the following for far too long now: public static DataTable myDataTable() { string sql = @"SELECT column1, column2, column3, column4 FROM...
4
by: Rachana | last post by:
Hi, I have understood Data Sets but what is meant by typed/untyped/ strongly typed datasets. Can any one explain me or suggest any site/ article, to get these concepts (and their ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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: 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...
1
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.