Question tableadapter default command

ghardy

Member
Joined
Mar 18, 2010
Messages
20
Programming Experience
10+
hi all,

i have a table adapter that i need to modify. the default command is one that combines multiple tables. a secdondary command is just the table. the problem is, that when i try and add one more field, it wants to rearrange the fields...i have a field "costcode", and it adds another field called costcode1, and unbinds the orginial. it does this to many fields, and i dont undertand why it adds some new fields and not all of them. additionally, if i do modify the darn thing, it removes the update, delete and insert statements from the table adapter.

How can i switch the default command to the second one, so that it will regen the dataset properly?

Is there a way to tell it not to do any automation, or do i need to muddle through the auto-gen'd code and change it there?

thanks!
 
I would suggest that you delete the DataTable from the DataSet and regenerate the Data Source, regenerating that DataTable from just the single table. You can then add another query based on a join and map it to a FillFromJoin method ro some other appropriate name.
 
yep...that was kinda my conclusion after thinking about it for a while. if i am to have a dataset that doesn't crap out every time i add a field or update a query, then the only reasonable conclusion is to make the default command come from the single table.

i did find the the designer code the declaration of the fill() and fillby() methods, each containing a parameter called "_default"...but when i switched the boolean flag on those, it seemed to have no effect.

i'll give that a try . thanks for your reply!
george
 
oh, and hope you and your family werent too badly affected by the flooding in the land down under....simply amazing and disasterous the amount of flooding down there. prayers go out to you all....
 
well, that did make things very painless...worked just as expected! however, it does bring an argument regarding how the table adapter and/or table work...

so i have two date fields. i would like to be able to insert null into these two fields under a certain circumstance. the database allows dbnull, the dataset allows dbnull, but the method to "AddNew[tablename]Row()" will NOT let you put a dbnull in the parameter list. this seems like something that microsoft overlooked.

if i go into the generated code and change the signature for that parameter to OBJECT, it will take it fine. it seems to me that if a column in a dataset will allow nulls, then the parameter should also be of type "object", and not strongly typed. Same with integers or decimals....

just thinkin.
 
You should find that if a column allows NULLs and it's data type is a value type then any method parameters that correspond to that column will be nullaable. The whole point of a typed DataSet is that it's typed, so such parameters being type Object is inappropriate. That would allow you to pass anything. You don;t use DBNull at all with a typed DataSet, so there's no need to use Object to facilitate that. With typed DataSets, nullable value types are used. Your DateTime column, if nullable, should be type Nullable(Of DateTime), or DateTime? for short. You then pass Nothing if you want NULL. The mapping between Nothing and DBNull.Value is done internally.
 
ah....i was unaware of that (setting to nothing). thanks a million....will be very useful in the future.

cheers.
 
Last edited:
Back
Top