Page 1 of 1

FW MariaDB/MySql native

Posted: Wed Dec 30, 2020 9:36 am
by Mike Serra
Hi to all Forum:

First of all I congratulate you on the holidays and wish you a good exit to the year of 2020 (screwed) and a better entry into 2021.

I would need help for the following: I have started to make examples of a CRUD of a table with the native functions of FWH (Ver. 16.10), and the code is similar to what I show:

1) I open the recordset and add a blank record

Code: Select all

oRs:=oConnection:Rowset("select * from operators")
....
oRs:Add()
 
2) I manipulate the fields

Code: Select all

oRs:Codigo:=  ¿¿¿¿¿
oRs:Nombre:=  ?????
 
3) Finally, I save the record.

Code: Select all

oRs:Save()
 
If the server does not give any errors, it works perfectly. The problem is that the table I am manipulating has a UNIQUE index in the "Codigo" field, so if I try to create a record with an existing code, it gives me an error, but the problem is that it is as if the pointer moved and gets lose their values ​​(they go blank). Do you know or do you have any example to be able to carry out this basic process?

Best regards, and thank you very much.

Re: FW MariaDB/MySql native

Posted: Sat Jan 02, 2021 6:49 am
by Mike Serra
:roll:

Re: FW MariaDB/MySql native

Posted: Sat Jan 02, 2021 9:37 am
by nageswaragunupudi
Please wait.

Re: FW MariaDB/MySql native

Posted: Sat Jan 02, 2021 11:56 am
by Maurizio
maybe it's the same problem ?

https://forums.fivetechsupport.com/view ... ql#p203181

Maurizio

Re: FW MariaDB/MySql native

Posted: Mon Jan 11, 2021 8:32 am
by Mike Serra
Good morning.

Any news?

Thanks in advance

Re: FW MariaDB/MySql native

Posted: Fri Jan 22, 2021 3:27 pm
by Mike Serra
Good afternoon.

any news?

Thanks in advance

Re: FW MariaDB/MySql native

Posted: Fri Jan 22, 2021 5:29 pm
by James Bott
Most databases automatically create the primary key when a new record is added. Thus they won't allow you to update the primary key.

DBFs are the exception to this, however there is now the option to specify an automatic primary key for DBFs too.

Re: FW MariaDB/MySql native

Posted: Mon Jan 25, 2021 8:56 am
by Mike Serra
Hello James:

Thanks for your comment. Actually, the problem I have is when trying to add a record and the server returns an error (in my case, because the code already exists). In this case, the values ​​of the oRs variable are lost. The code field has created a unique index on the server.

I could carry out this check, but I prefer to control it more securely at the database level, because the application can be accessed from desktop software and web applications.

Thanks.

Re: FW MariaDB/MySql native

Posted: Mon Jan 25, 2021 2:33 pm
by James Bott
Mike,

I guess I wasn't clear, all you have to do is use automatic primary keys with DBFs. You do this by using the field type "+" for the primary key field. Then when you add a blank record it will automatically get a primary key ID. This way you can use the same code for both DBFs and SQL databases.

Or, maybe still I don't understand your problem?