Forum > Databases

Can't get MySQL + SQLdb + dbGrid working...

(1/1)

netsolute:
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: ---procedure TForm1.Button1Click(Sender: TObject);
begin
  MySQL50Connection1.Connected:=True;
  SQLQuery1.Open;
end;    
--- End code ---

And:

--- Code: ---procedure TForm1.Button2Click(Sender: TObject);
begin
  SQLQuery1.Post;
  SQLQuery1.ApplyUpdates;
  SQLTransaction1.Commit;
  SQLQuery1.Close;
end;
     
--- End code ---

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! :)

Navigation

[0] Message Index

Go to full version