columns with type of UInt16, UInt32, or UInt64 autoincrement problem RRS feed

  • Question

  • I do not wy but that the DataColumn class in .NET 1.1 and 2.0 does not allow columns with type of UInt16, UInt32, or UInt64 to be autoincrement
    I use autoincremement columns with MySQL, And Updates commands from my datasets tableadapters does not work, becouse when i try to  add a new  row  an error is throwed telling me that  primary key from table afected does not allow to be null

    I be Investigating how works MySQL interacting with ADO.NET to try to solve this problem

    with the new ADO.Net 2.0 API, Microsoft did not directly provide for any type of API that users could use for selecting this.  With ADO.Net 2.0, there are two things that need to happen.  First, a SELECT statement similar to "SELECT last_insert_id() FROM table" must be attached to the INSERT command.  Second, the command object must have its UpdatedRowSource property set to Both or FirstReturnedRecord.  What this does is tell the data adapter update engine to take the first returned row and merge it's values back into the changed row.

    After All that I did find the way to solve this problem, with little code because all proyect is coded and is dificult to do all this refactoring

    Place give me a hand

    Wednesday, January 30, 2008 2:47 PM

All replies

  • I believe signed types (Int16, Int32 and Int64) do this job perfectly. Do you really need to use UIntXX types?


    Thursday, January 31, 2008 11:31 AM

    I think this kind of problem is becouse people don´t consider the UInt types to be AutoIncrement, I have to solve this problem becouse the all database relational schema the PK are Unsigned and the TableAdapters Throws errors in everyplace, becouse the autoincrement feature doesn´t exist.


    Now I´m working rewriting code (the time is gold nowadays) to solve problems not Using the simple statement

    TableAdapter.Update(DataTable) -> That do a lot of work for us


    Thanks for your help

    Wednesday, February 6, 2008 7:07 PM