Recent

Author Topic: How work Update and Insert on MySQL5 ?  (Read 6893 times)

arwen

  • Full Member
  • ***
  • Posts: 104
    • http://www.flussiliberi.it/
How work Update and Insert on MySQL5 ?
« on: May 10, 2007, 03:05:13 pm »
I have a little application with

1 MySQLConnection
1 SQLTransaction
1 SQLQuery
1 DataSource
1 DBGrid

I can connect to a table of a database and show the data in the dbgrid but if I modify some value what I must make in order to update this or to insert a new record ?

I'm going mad because I don't know how works the MySQL components  :x

Thanks to all

arwen

  • Full Member
  • ***
  • Posts: 104
    • http://www.flussiliberi.it/
How work Update and Insert on MySQL5 ?
« Reply #1 on: May 14, 2007, 10:56:41 pm »
The only way to solve is execute one query of insert or update?
Do not exist any autoupdate automatism ?

Why don't work the sintax autocomplete of a MySQLConnection object?

Where I can find the source of MySQL50Connection to understand how it work ?

Thanks to all.

RudieD

  • Full Member
  • ***
  • Posts: 234
How work Update and Insert on MySQL5 ?
« Reply #2 on: May 16, 2007, 06:32:43 pm »
Did you do
Code: [Select]
 SQLQuery1.ApplyUpdates;
  SQLTransaction1.Commit;
?
The FRED Trainer. (Training FRED with Lazarus/FPC)

jzombi

  • Newbie
  • Posts: 6
How work Update and Insert on MySQL5 ?
« Reply #3 on: June 07, 2007, 03:51:37 am »
Quote from: "arwen"
The only way to solve is execute one query of insert or update?
Do not exist any autoupdate automatism ?

Why don't work the sintax autocomplete of a MySQLConnection object?

Where I can find the source of MySQL50Connection to understand how it work ?

Thanks to all.


Hi!

The autocomplete will not work, becouse the TMySQL50Connection is a macro defined class. You can find the code, if you look after the declaration of the mysql50conn unit. It includes in the mysqlconn.inc, and the TMySQLConnection classes are defined there.

I've modified your program, so you can now change the data, and you can add new fields to a table too.
You can download it from here:
http://digitus.itk.ppke.hu/~janma/lazarus/MySql5Test.tar.gz
I hope, you'll find it useful.

Regards.
ps. sorry, my english is very bad after midnight:)

arwen

  • Full Member
  • ***
  • Posts: 104
    • http://www.flussiliberi.it/
How work Update and Insert on MySQL5 ?
« Reply #4 on: June 14, 2007, 10:12:00 am »
Thanks jzombi.

I try the modified program and it works fine .  :D

So now I will make some other question  :lol:

Why if I have a table with a Column of Text Data Type I can't visualize it on the grid ?
For text I can only use Char Data type on the grid ?

Why if I insert a new record in a table like below

ID (integer) , NUMBERS (integer)

where the columns NUMBERS is defined with a Defalult value NULL
and I write nothing in this column than
when I reopen the table I can't modify the value by the grid ?

I can modify the value only executing a Query of REPLACE   :shock:

Regards.
ps. sorry, my english is very bad always !  :oops:

pjensen

  • New member
  • *
  • Posts: 7
How work Update and Insert on MySQL5 ?
« Reply #5 on: August 05, 2007, 01:47:45 pm »
@jzombi:
Hi, i want to write a liitle "mysql-db-changer" with lazarus.

I downloaded your MySQL5Test.tar.gz.
I have a MySQL-Database called "adm" with a table called "clients".

This is the table clients:
http://web6.vs251197.vserver.de/before_change_adm.sql

I can change an entry, (sqlquery: "select * from clients") but
when i change an entry something stupid happens:

In most cases when i change one entry, for ore more entrys in the same colum are changed to the same value.

E.g when i change "Company No2" (company-entry  from the second row) to "kkk", than some other entrys from column "company" are also changed to "kkk".

Yesterday, in most cases row 2,3,4,5 where changed. Today all Companys ars set to "kkk" when i change "Company-No2"

The result:
http://web6.vs251197.vserver.de/after_change_adm.sql



What the heck is my mistake?


For Info:

1) I have to say, that I'm a newbie on lazarus and on mysql.

2) I'm working and compiling at 192.168.10.93.
with lazarus 0.9.22beta.
It's a OpenSuse 10.2 / KDE.

3) I have mysql 50 running on 192.168.10.94.
there is the database "adm" with a table "clients"
OpenSuse 10.2 --- KDE --- Lazarus 0.9.22 beta with gtk1

panjas51

  • New Member
  • *
  • Posts: 13
How work Update and Insert on MySQL5 ?
« Reply #6 on: February 09, 2008, 10:58:26 am »
Bravo !!!!!

Thanks a lot


Quote from: "jzombi"


I've modified your program, so you can now change the data, and you can add new fields to a table too.
You can download it from here:
http://digitus.itk.ppke.hu/~janma/lazarus/MySql5Test.tar.gz
I hope, you'll find it useful.

Regards.
ps. sorry, my english is very bad after midnight:)

 

TinyPortal © 2005-2018