Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
AddRow and defaults/nulls
Message
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
00771678
Message ID:
00775612
Vues:
15
Hmm... I was told it does. I ran a little test and it does get the nullability and the constraints...but as you say, it doesn't seem to get the defaults. I don't know why it doesn't get the default.

Well, I guess you could query the schema of the table you are working with and populate the default values of the DataColumns in the dc collection. Not pretty but if it is in your class you only have to write the code once.

BOb


>>Are you using a DataAdapter to fill the dataset? It is my understanding that if you do this the DataAdapter will also populate the dataset with the constraints, relations and defaults from SQL server automatically.
>
>Yes, and no it doesn't appaer to do this. At least not automatically...
>
>+++ Rick ---
>
>>
>>BOb
>>
>>
>>>Hi all,
>>>
>>>I'm looking for some best practices ideas on how to deal with adding new
>>>values to a DataSet after I've pulled some data down.
>>>
>>>The biggest issues I have are:
>>>
>>>* AddRow adds everything with nulls
>>>* I get no default values from the database
>>>* The dataset updates propagate the nulls to the server so
>>> even on the Insert that occurs the default values aren't set.
>>>
>>>Short of manually executing Insert Statements and reading the data back is
>>>there a better way to have the Dataset respect the database settings and
>>>constraints defined in the database (SQL Server)?
>>>
>>>Right now as it stands I have a routine that initializes most values to
>>>non-null values then explicitly follow up the fields that need to have
>>>specific values (or null) set. It's not a big deal, but this sort of thing seems very inefficient requriing lots of extra code... (well actually my BO has some code that can do this automatically setting everything to VFP style blanks rather than nulls).
>>>
>>>Dealing with NULLS in ADO.NET is a PITA too because you have use DBNull for all comparisons etc. so I'm even less inclined to ever use NULLs in any data except those that REALLY require it for knowledge of previously unset values (most don't).
>>>
>>>
>>>Any ideas?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform