in

System.Data.SQLite

An open-source, enhanced version of the SQLite database engine for Windows

Default values not set in typed dataset

Last post 03-28-2008 3:48 AM by indiekiduk. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 02-20-2006 7:05 AM

    • alex
    • Top 25 Contributor
    • Joined on 02-07-2006
    • Posts 23

    Default values not set in typed dataset

    Hi,

    it seems like default values are not set. With the following schema all column default values remain
    set to DBNull when the table is dropped onto the dataset designer. I used release 1.0.26.2.

    CREATE TABLE NodeLayout(
                    NodeId INTEGER PRIMARY KEY UNIQUE,
                    X REAL NOT NULL DEFAULT 0,
                    Y REAL NOT NULL DEFAULT 0,
                    Width REAL NOT NULL DEFAULT 30,
                    Height REAL NOT NULL DEFAULT 40
                    )

    Regards,
        Alexander

  • 02-20-2006 8:23 AM In reply to

    Re: Default values not set in typed dataset

    Hrm ... I'll look into it.

    Robert

     

  • 02-20-2006 10:33 PM In reply to

    Re: Default values not set in typed dataset

    I checked into this.  SQL Server does the same thing.  I setup a table in SQL Server with some column defaults, and made a typed dataset out of it.  It came out the same way as SQLite did.

    It makes sense, though.  The typed dataset should not be assigning any default values, it should be letting the database do that.  If it didn't, then if you changed the database's default value you'd have to recompile your program because your typed dataset would be inserting the wrong default value.

    Robert

     

  • 02-21-2006 4:20 AM In reply to

    • alex
    • Top 25 Contributor
    • Joined on 02-07-2006
    • Posts 23

    Re: Default values not set in typed dataset

    For the NOT NULL DEFAULT case one could argue, that the default values won't be assigned by the database, because Rows.Add() will throw a NoNullAllowedException if you try to insert NULLs. So, having default values being assigned by the dataset can make sense in that case.

    OTOH, I like having the NULL checking, because it catches missing assignements to columns.


        Alexander



  • 02-21-2006 7:46 AM In reply to

    Re: Default values not set in typed dataset

    I don't disagree with you ... however, it looks like this is a deficiency in the typed dataset code generator and not in SQLite.  I tested several typed datasets in Sql Server with tables defined with not null and a default value, and the typed dataset generated the same code for each case.

    Robert

     

  • 02-21-2006 8:46 AM In reply to

    • alex
    • Top 25 Contributor
    • Joined on 02-07-2006
    • Posts 23

    Re: Default values not set in typed dataset

    The current behaviour is ok for me. I was just wondering if there's a better solution.
    Thanks for you help.

    Btw, the current release works pretty good for me.

    Regards,
        Alexander
  • 03-28-2008 3:48 AM In reply to

    • indiekiduk
    • Top 150 Contributor
    • Joined on 09-08-2006
    • Glasgow, Scotland
    • Posts 7

    Re: Default values not set in typed dataset

    Could you please comment on this related issue. Even though my sqlite table column allows null and AllowDBNull is set to true in the dataset field, the AddRow function is taking a double and not a double? meaning I can't actually pass in null. More detail on this issue from someone else is here, including my workaround in the last post: http://forums.asp.net/t/1227689.aspx Thanks
Page 1 of 1 (7 items)
Powered by Community Server (Commercial Edition), by Telligent Systems