Topic: Can't mark database field as "not null"

When I created my first table I had no problem making 1 field "not null". However, when I made my second table, I was not able to make any field "not null". Maybe I'm missing something? I've attached the database file. Maybe someone can tell me where I went wrong. Thanks a bunch.

Post's attachments

Attachment icon Contacts.vdb 19 b, 442 downloads since 2015-12-07 

Nothing inspires forgiveness quite like revenge.

Scott Adams

Re: Can't mark database field as "not null"

It is not possible to open only the vdb file, you have to join the other files without .exe and .dll as the other files contain the structure of the database and the layout of the project.

Re: Can't mark database field as "not null"

Hi tcoton, Thanks for writing. If I understand what you wrote, you need me to attach my project without the exe and dlls. So, here it is, let me know if I did not understand.

Post's attachments

Attachment icon Contacts.7z 808.72 kb, 372 downloads since 2015-12-07 

Nothing inspires forgiveness quite like revenge.

Scott Adams

Re: Can't mark database field as "not null"

Hello Jumper,
Usually you will get this problem if you have already started to add data to your project in ANY of your tables, not just the table that you are trying to make a field not nullable in.
In the directory where your project files are held, delete the sqlite.db file, go back into your project and you should then be able to make the required field not nullable.  For this reason, it's best to only enter a small amount of test data until you're 100% sure of the structure, conditions etc to avoid having to re-enter stuff.
Hope this helps,
Derek.

Re: Can't mark database field as "not null"

Thanks Derek. I tried your solution and I'm not sure if it worked. But I did manage to mark the field as "not null". I know this is dumb, but I went to the edit icon for the field. From there I went to the "additional" + sign and from there I could change the field type there. Thanks for writing back with an answer. Really appreciate the help.

Nothing inspires forgiveness quite like revenge.

Scott Adams

Re: Can't mark database field as "not null"

Hi Jumper,
Yes, my understanding is that you have to use the 'edit' icon and then the 'additional' option - you can't simply insert a tick on the first 'database tables' screen (even though it looks like it you can).
Notwithstanding that, you would still hit your original problem if you'd already started adding data to any of the tables.
Derek.

Re: Can't mark database field as "not null"

jumper
I suppose you got this error message?

---------------------------
Error
---------------------------
Since the database is already created.
Cannot add a NOT NULL field without a default value.

Please enter the default value.

Either you must delete the database file sqlite.db, in order to be automatically recreated.
---------------------------
OK   
---------------------------

Please pay attention to this "Please enter the Default value."

Dmitry.

Re: Can't mark database field as "not null"

Yes, there is a logic here, if you set a column to not null, there must be a default value e.g: 0 or 1

9 (edited by jumper 2015-12-10 00:30:53)

Re: Can't mark database field as "not null"

Edit: Thanks for all the help guys...

Nothing inspires forgiveness quite like revenge.

Scott Adams