Q: Disconnected DataSets - automatic Add/Remove but with Guid Key instead of AutoIncrement int?

  • Thread starter Thread starter Sky
  • Start date Start date
S

Sky

Hello,
The books on C# I have read, talk of using the DataSets in disconnected
mode,
and Adding/Removing/Updating records from it, and letting it handle all the
updating on the Database in one batch finale...

But the examples were all based on using auto-increment columns.

Lately I've been backing away from Auto-Increment columns to move to
'uniqueidentifier' guid columns instead for my Key columns -- to allow for
better synching arch. with several disconnected PocketPC's in the future...
(So I've been told this is what can be done...)

Question:
How does one get to use this disconnected abilities of the DataSet if using
Guid's --
AND where I need to provide a new Guid() programmatically at post time if it
is a new record
(why? Because on SqlServer there is a command to do so -- but when porting
to MySQL where they don't have a built in function to generate a Guid if
none provided, you have to provide the value before posting...)

Voila. Convoluted question -- I apologize -- but any info, or better yet
short code sample,
anything that would get me to see the light on this one, would be FANTASTIC!
Sky
 
Depending on the exampel the autoincrement was probably a key field which is
necessary for the commandbuilder and DataAdapter configuration wizard to gen
Update/Insert/Delete Logic.

If you have GUID column, just dont' pass anything to it..it will take care
of itself on the update (unless it's your key) but even if it is, just leave
it alone and it will fill itself for you once it gets back to the DB.

HTH,

Bill
 
Hi William:
Just want to check the last paragraph...
I am trying to keep the code portable between the two dbms's we use here
(SqlServer/MySQL).
Since MySQL doesn't have uniqueidentifiers we use string (36) for those...It
also doesn't have
a trigger to automatically generate a Guid. With those points in mind:
Are you saying that the DataSet itself is smart enough to auto-generate a
new one if non-provided,
or can I trap a NewRecord() function of some type and inject a new
System.Guid there?

Would you have 5 lines of code to show me how I could do this?
Thanks so much,
Sky
 
I'm not sure about MySql, but in general, since those values are generated
automatically, if you just don't include them in the update, the DB itself
will create them for you. Let me check into MySql....
 
Back
Top