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:
00771732
Vues:
9
Working with the DataColumn.DefaultValue won't change anything you're doing but it might save some code.
http://www.dotnet247.com/247reference/msgs/18/91618.aspx

Also, (I haven't tried this) but what if you
1. Set the default values in code
2. Call DataSet.AcceptChanges that will reset the modified flag
3. Make edits and update the dataset

Do the SQL defaults stay set?


>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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform