Recent

Author Topic: access violation with mysql  (Read 15606 times)

gecob

  • New Member
  • *
  • Posts: 12
access violation with mysql
« on: March 13, 2006, 12:03:09 am »
Hi to all!
I'm trying mysql with my first app!
I've a problem with the connection to db, in particular I've a access violation error when I try to make an insert query!
I use mysql 4.1 and lazarus 0.9.13.
Yo make connection I use the components under SQLdb!
This is the code:
Code: [Select]

MySQLConnection1.HostName := 'localhost';
  MySQLConnection1.UserName := 'root';
  MySQLConnection1.Password := 'my_pw';
  MySQLConnection1.DatabaseName := 'db_test';
  pagamento:=DDpagamento.Text;
  conto:=DDconto.Text;
  MySQLConnection1.Open;
  SQLQuery1.SQL.Text := 'INSERT INTO entrate (tipoconto,importo,data,descrizione,tipopagamento) values (conto,TBimporto.Text,TBdata.Text,pagamento)';
  SQLQuery1.ExecSQL;
  SQLQuery1.Close;
  MySQLConnection1.Close;

Thanks!

matthijs

  • Hero Member
  • *****
  • Posts: 537
RE: access violation with mysql
« Reply #1 on: March 13, 2006, 07:38:17 am »
Can you tell us when the AV happens? It looks like you are trying to use a component which is not created yet. So make sure you have the Connection, Transaction and Query created before assigning values to properties.

But based on the information you have given, we can only guess.
What's in a sig? Would my posting look less if it didnot have a sig? (Free after William S.) :)

:( Why cannot I upload my own Avatar? :(

Anonymous

  • Guest
access violation with mysql
« Reply #2 on: March 13, 2006, 01:53:13 pm »
The error happens when I try to make

SQLQuery1.SQL.Text := 'INSERT INTO entrate (tipoconto,importo,data,descrizione,tipopagamento);

matthijs

  • Hero Member
  • *****
  • Posts: 537
access violation with mysql
« Reply #3 on: March 13, 2006, 09:45:23 pm »
In your code is the complete text on one line in the editor? If not try to do it like
Code: [Select]

SQLQuery1.SQL.Text :=
  'INSERT INTO entrate (tipoconto,importo,data,descrizione,tipopagamento)' +
  ' values (conto,TBimporto.Text,TBdata.Text,pagamento)';

Also make sure SQLQuery1 is created before assigning a value to the text property.
What's in a sig? Would my posting look less if it didnot have a sig? (Free after William S.) :)

:( Why cannot I upload my own Avatar? :(

gecob

  • New Member
  • *
  • Posts: 12
access violation with mysql
« Reply #4 on: March 15, 2006, 10:02:15 pm »
Yes my code the complete text is on one line!
I've also try the example downloaded from sourceforge, and I've the same error!
It connects to server, but when there's a query to, it returns the error!
There are other component to access mysql 4.1?

gecob

  • New Member
  • *
  • Posts: 12
access violation with mysql
« Reply #5 on: March 15, 2006, 10:31:51 pm »
I think the problem is the the component TMySQL4Connection that I use.
I run mysql server 4.1, so I've to use TMySQL41Connection, but how can I install this component?

gecob

  • New Member
  • *
  • Posts: 12
access violation with mysql
« Reply #6 on: March 17, 2006, 02:05:44 pm »
I've update to a new snapshot of lazarus, and now in my sqldb tab i can find TMYSQL41Connection, but if inset this component in my project, when I run it I recive this errore:

/usr/lib/lazarus/components/sqldb/registersqldb.pas(3134) Fatal: Can't find unit sqldb

Why?

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
access violation with mysql
« Reply #7 on: March 17, 2006, 02:11:43 pm »
Quote from: "gecob"
I've update to a new snapshot of lazarus, and now in my sqldb tab i can find TMYSQL41Connection, but if inset this component in my project, when I run it I recive this errore:

/usr/lib/lazarus/components/sqldb/registersqldb.pas(3134) Fatal: Can't find unit sqldb


Did you use the fpc rmps from the snapshots too?

Anonymous

  • Guest
access violation with mysql
« Reply #8 on: March 17, 2006, 07:00:48 pm »
I resolve reinstalling the new fpc!
Thanks!

gecob

  • New Member
  • *
  • Posts: 12
access violation with mysql
« Reply #9 on: March 17, 2006, 08:09:19 pm »
I've again the same error, also with the new component TMysql41Connetion!!
I don't know what to do :(

jrmarino

  • New Member
  • *
  • Posts: 24
access violation with mysql
« Reply #10 on: March 17, 2006, 09:20:27 pm »
I just wrote a new database API specifically for mysql 4.1 and 5.0.  It's the top article on the first page of this site.  It works with FPC 2.0.2, and doesn't require lazarus.  I've written pascal programs in both delphi and FPC with it.  If your having trouble with TMySql41Connection, you might try what I wrote.

https://trac.synsport.com:8000/index.php/pdo
username/password = guest/guest

It's possible to get access violations with it too, but that's normally caused by passing bad SQL and not checking for an error code before trying to process it.  Maybe that's your problem with TMysql4.1Connection.  Garbage IN can definitely cause an access violation with the mysql dlls.

gecob

  • New Member
  • *
  • Posts: 12
access violation with mysql
« Reply #11 on: March 18, 2006, 01:42:59 am »
When I add mysql component, i can't use it in fact i've the error SQLdb unit not found!
Why?

Anonymous

  • Guest
access violation with mysql
« Reply #12 on: April 18, 2006, 01:15:30 pm »
Where is the components TMysql41Connection and TMysql5Connection? I cannot find in my sqldb table! I really need help please!

johnf

  • New Member
  • *
  • Posts: 18
access violation with mysql
« Reply #13 on: April 19, 2006, 12:12:18 am »
There is a tutorial on how to use MySQL on the wiki.  Please read that.  

To answer your question directly they are under the 'SQLdb' tab in the Lazarus IDE.
John

 

TinyPortal © 2005-2018