autoincrement fields

I made a forma nd placed a field there. Then I made a method that creates new record and placed a button that calls that method.
The problem is that when a record is created the field that should autoincrement gets set to 0, and only if I go to designer mode and then back I get field to autoincrement.

I used controller.newRecord() in a method.
What may I be doing wrong?

Can you show what your method looks like and which version you use?

database auto increment?

then you first have to do a save…

What happens for example if you create 2 newRecords after each other.. What id does the first one have?

here is the method:
controller.newRecord();
that’s all I did.
If I create two after each other, they both get set to 0 until I go to designer mode and back, then they are set to right values.
I use latest evaluation version on Windows XP
Thank you

Is the increment set by Servoy or by the database itself?

by the database, but I need to keep it by database , because I want to build web site for that database

In that case did you pay attention to the remark of Johan about performing a save (controller.saveData()) after performing the controller.newRecord();

this is how my method looks like now:

controller.newRecord();
controller.saveData();

still same problem, I even restarted servoy to make sure the method is saved.

Who is Johan and where did he say that?

Johan = Johan Compagner from Servoy also replying to your post earlier.

But anyway, I am out of options maybe the guys from Servoy can help you further. Sorry…

this is funny
I changed my method like this:

controller.newRecord();
controller.sort(String);

and it worked.
Note I didn’t even replace the ‘String’

are you sure that it really didn’t get saved or is the pk just not updated quite right after the save?

when you start servoy with java.exe -DSTACKTRACE=TRUE -jar servoy_developer.jar

you will see something like this when you call controller.saveData()

sql insert into test(TESTID,INTEGER1,DATE1,TEKST) values (?,?,?,?,?,?)
questiondata[2] 1
questiondata[3] -10
questiondata[4] 1970-01-01 00:00:00.0
questiondata[5]

do you see that?
And what output around that do you also see?

Can you send me a reproducable example solution where i can see that youre pk is never updated?

What database do you use?

Johan, (I understand you are Johan)

I’m attaching the picture of what I get… hope I did what you told me to.

I’m using MySQL which is on other machine(OSX) I tie in to it using Windows

what is youre pk column for that table?
do you configured it as a database sequence in the dataprovider dialog?

Johan, you are dealing with recent graduate girl, and I still don’t understand many things…
I assume you mean Primary Key by ‘pk’ and I don’t understand what you mean by database sequence.
I’m attaching a picture of how the data provider is set, hope it will help.

ok i see youre problem..

JobNumer is youre primary key.. But youre sequence type of that row (last column) is none. You have to set that to the sequence type you want and that is database sequence…

or else servoy doesn’t know that you are using a database sequence.

OK, then I have another question.
When I just create a new field I can set the database sequence, but if the field is already created I am not able to change it.
Can you tell me how to change it?

what version of servoy do you use?
because that is fixed some builds ago!

this is what it says in about section

Servoy Developer
Version R2 2.0 beta6-build 260

Copyright M-) 1997-2003
Servoy BV
www.servoy.com

I’m using evaluation version that I downloaded about a week ago

thats an old version yes

see

http://forum.servoy.com/viewtopic.php?t … eta+update

or you can wait for RC11 which should be around the corner pretty soon as a complete download.