Recent

Author Topic: Can't get MySQL + SQLdb + dbGrid working...  (Read 3983 times)

netsolute

  • Newbie
  • Posts: 1
Can't get MySQL + SQLdb + dbGrid working...
« on: April 12, 2007, 07:23:10 pm »
My server is having MySQL 5.

I create a new form, then I put a TMySQL50Connection on it, a TSQLTransaction, a TSQLQuery, a TDataSource and a TDBGrid. At designtime I set

MySQL login + db info in MySQL50Connection1
MySQL50Connection1.Transaction to SQLTransaction1
SQLTransaction1.Database to MySQL50Connection1
SQLQuery1.Database to MySQL50Connection1
SQLQuery1.Transaction to SQLTransaction1
SQLQuery1.SQL (.add) to 'SELECT * FROM table'
DataSource1.DataSet to SQLQuery1
dbGrid1.DataSource to DataSource1

Then I make 2 buttons, and I add the following code to them:

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
begin
  MySQL50Connection1.Connected:=True;
  SQLQuery1.Open;
end;    

And:
Code: [Select]
procedure TForm1.Button2Click(Sender: TObject);
begin
  SQLQuery1.Post;
  SQLQuery1.ApplyUpdates;
  SQLTransaction1.Commit;
  SQLQuery1.Close;
end;
     

Now if I open the database using button1, everything works fine. But when I edit then a thing in the dbGrid, and press button 2, my program hangs at the ApplyUpdates command, and gives me a EDatabaseError. (No specs.)

I have no idea how to debug this. Please give me some help! :)