in

System.Data.SQLite

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

allow dbNull? no no no! :)

Last post 08-21-2007 8:18 AM by Robert Simpson. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 08-13-2007 12:46 AM

    • Wiaz
    • Top 25 Contributor
    • Joined on 01-11-2007
    • Poland
    • Posts 47

    allow dbNull? no no no! :)

    It's a big big bug:) I tried to solve this problem since I remember because i thought it was on my side but now i have discovered the problem. Make databse in some manager with table with column that can hold integer but without 'not null' constraint! Simple integer column with allowed null values. Then make dataset with wizard in visual C# express edition for example. And now is the thing: when you use dataadapter.Fill method (generated by wizard not written by me) to populate data into dataset.datatable then: 1.if you have column with all values different from null all is ok, 2.if FIRST row has null value in that column and the rest is whatever-you-want , all is correct 3. but if you have in the FIRST row in that column an integer value then: if Fill populating method meet null value in some further row it raises error: field cannot hold "<>" value in this column, it expects an Int64. !!!!!!!!!!!!!!!!! I did it then after compiling application, and the only thing i did was to change values in the table in some databasemanager and then run my app. If i have values in column in order i wrote i had error or hadn't, it depeneds on the first row value, if it has a null or not.
    Wiaz
    Filed under:
  • 08-15-2007 9:52 PM In reply to

    • Wiaz
    • Top 25 Contributor
    • Joined on 01-11-2007
    • Poland
    • Posts 47

    Re: allow dbNull? no no no! :)

    HI! no answer but i discovered something. I spent lots of time, but discovered realy simple thing! I'm using tkSQLite manager during development to manage database. When I use empty value in column then it is an error when i want to update or delete a row from database. These is because of generating queries in dataset wizard in 'optimistic' kind of way! When I configure tableadapter and unchek this 'optimistic' query option and make simple query with only primary key in 'WHERE' expression then the problem dissapears! Then: the problem is with handling empty columns. I dont know what other apps insert instead of null/dbnull value, but the point is: if I insert row with empty column by your wrapper then all is ok, but if I insert record with empty column with e.g. tkSQLite manager then I have an error when I want to update row (in optimistic query generated by dataset wizard of course).
    Wiaz
    Filed under:
  • 08-15-2007 10:42 PM In reply to

    • Wiaz
    • Top 25 Contributor
    • Joined on 01-11-2007
    • Poland
    • Posts 47

    Re: allow dbNull? no no no! :)

    one more thing:the problem is that you insert into database and update empty columns with dbnull.value i think. there will be always problem because I can do inserts or updates without all columns. for example table has: id, col1, col2, col3... and when i query with "INSERT INTO [table] (col2) VALUES ('value')" ! then col1 and col3 will have null or default values inserted by genuine sqlite.dll. If there is no default value then there will be error with your optimistic update because in empty columns there are no dbnull.value even though there are empty!
    Wiaz
    Filed under:
  • 08-21-2007 8:18 AM In reply to

    Re: allow dbNull? no no no! :)

    This particular problem is beyond my control and boils down to the automatic SQL generation of Visual Studio.  I'm providing Visual Studio with all the information necessary, but for some reason it doesn't pull default values from the schema even if I provide them.

     

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