in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

DataSet generated with GUID column has incorrect type for parameters

Last post 12-29-2011 11:08 PM by RyanLosh. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 08-14-2010 12:59 PM

    DataSet generated with GUID column has incorrect type for parameters

    First off, thanks for the great work.  It's invaluable, but I found one problem in using GUID columns. 

    Given a table with a GUID as the column.

    CREATE TABLE [Account] (
     "AccountId"  guid NOT NULL,
     "IdNumber"  integer PRIMARY KEY AUTOINCREMENT NOT NULL,
     "Slug"  nvarchar(255) NOT NULL COLLATE NOCASE,
     "Title"  nvarchar(255) NOT NULL COLLATE NOCASE,
     "Description"  nvarchar(1024) COLLATE NOCASE,
     "Approved"  bit NOT NULL,
     "Deleted"  bit NOT NULL,
     "CreateTimeUtc"  datetime NOT NULL,
     "UpdateTimeUtc"  datetime NOT NULL,
     "UpdateUser"  nvarchar(255) NOT NULL COLLATE NOCASE

    )

    Creating a dataset from the table, the dataset identifies the "AccountId" correctly column as a GUID.

    Then, either configuring the default dataset query, or adding a new query with a parameter:

    SELECT [AccountId], [IdNumber], [Slug], [Title], [Description], [Approved], [Deleted], [CreateTimeUtc], [UpdateTimeUtc], [UpdateUser] FROM [Account]
    WHERE (@AccountId = [AccountId])

    Then, the Dataset.Designer.cs generated contains an invalid type (actually two type lines are generate, both incorrect.

    param.ParameterName = "@AccountId";
    param.DbType = global::System.Data.DbType.Object;
    param.DbType = global::System.Data.DbType.Currency;

    Changing the generated code manually such that the correct type is generated, resolves the issue.

    param.ParameterName = "@AccountId";
    param.DbType = global::System.Data.DbType.Guid; 

    If the default generated code is used, then an exception is thrown:

    {"Unable to cast object of type 'System.Guid' to type 'System.IConvertible'."}

  • 08-15-2010 3:05 PM In reply to

    Re: DataSet generated with GUID column has incorrect type for parameters

    Answer

    This should be fixed with the next patch.

  • 12-11-2011 12:03 PM In reply to

    Re: DataSet generated with GUID column has incorrect type for parameters

    Has this been patched yet? I got set up about a month ago. I guess that's the April 18th build.

    I'm trying to use tables with GUID primary keys. The Visual Studio Data Set designer won't generate update and insert commands because of how the select query is constructed (joins, || concatenate operators, and other weirdness), so I had to manually set the commandtext of the insert and update commands, but then I get this error when calling update on the table adapter:

    Error saving the form: Unable to case object of type 'System.Guid' to type 'System.IConvertible"

    The fix above worked for me as well.


     

  • 12-29-2011 11:08 PM In reply to

    • RyanLosh
    • Not Ranked
    • Joined on 12-30-2011
    • Maryville
    • Posts 1

    Re: DataSet generated with GUID column has incorrect type for parameters

    I Was Working MySQL Query , I Would To Share Some EXperience With You Guys ,

    MySQL Totally work on the table Format in Which their Are number of parameter in the Table And We can Take Out Any Parameter With the help of MySQL Query but It was Found in One Of the Table that  Some Other PArameter Was visible in Other Table which is nothing but the Bug and a good example of DataSet generated with GUID column has incorrect type for parameters ..

    :) :) :D

Page 1 of 1 (4 items)
Powered by Community Server (Commercial Edition), by Telligent Systems