Recent

Author Topic: MySQL50 - newbie problem (Windows)  (Read 18047 times)

rturney

  • New Member
  • *
  • Posts: 48
MySQL50 - newbie problem (Windows)
« Reply #15 on: May 05, 2007, 01:05:23 am »
For some reason that I can't explain, I have gotten past the previous problems.  I was thinking I'd try the "SQLQuery1.Open;" again instead of "SQLQuery1.ExecSQL;" and maybe the "SQLQuery1.First;" statement would then work.  It did!!!!  Here's what I used:
Code: [Select]
 // First lets get a list of available databases.
  if MySQLConnection1.Connected then begin
    ShowString('Connected to server: ' + HostEdit.Text);
    ShowString('Retrieving list of available databases.');
    SQLQuery1.SQL.Text := 'show databases';

    SQLQuery1.Open;
    {SQLQuery1.ExecSQL;}

    if SQLQuery1.Active then begin
       SQLQuery1.First;
       ShowString('SQLQuery1 is Active');
       end
       else
       ShowString('SQLQuery1 is not Active');
       
    while not SQLQuery1.EOF do begin
      ShowString('Inside loop');
      DatabaseComboBox.Items.Add(SQLQuery1.Fields[0].AsString);
      SQLQuery1.Next ;
    end;
    SQLQuery1.Close;
    ShowString('List of databases received!');
  end;

Out of curiosity, I commented out the "if SQLQuery1.Active then begin" statements and re-ran the program.  And to my surprise it also ran without any errors!  In both variations the DatabaseComboBox was filled with the database names in my MySQL.  

I'm not sure how to explain this because now I am back to the original code that was used in the tutorial!!!!  And this is what caused arwen to originate this thread.  Arwen (using Windows) and I (using Linux) would get an error stating:
Quote
MySQLConnection1: Error executing query: You have an error in your SQL syntax; Check the manual that corresponds to your MySQL server version for the right syntax to use near " at line 1.

Maybe one of the Lazarus developers can shed some light on this.

Now that I got past that problem, with the program still running, in the DatabaseComboBox, I clicked on a simple database I had created in MySQL called "addressbook" with a table called "tbl_friends".  When I clicked the SelectDBButton I got the following error:
Quote
Operation cannot be performed on an active dataset.

I am still looking at this latest problem and will post any progress I make to this thread.  I suppose I should post to this thread.  Maybe I should start a new thread?

arwen

  • Full Member
  • ***
  • Posts: 104
    • http://www.flussiliberi.it/
MySQL50 - newbie problem (Windows)
« Reply #16 on: May 05, 2007, 09:04:42 am »
I try your code but I receive only the old error message [On Windows]. :cry:

This Weekend I'll try the Zeos components  :evil:
I need to use a MySQL database . I must use it . :twisted:

Thanks to all and have a Good WeekEnd  :wink:

bram

  • Newbie
  • Posts: 5
MySQL50 - newbie problem (Windows)
« Reply #17 on: May 07, 2007, 01:21:49 pm »
Note: SQLQuery.ExecSQL does not create a result set, whereas SQLQuery.Open does.

For a query like SHOW DATABASES, it is best to set
Code: [Select]
SQLQuery.ParseSQL:=false;
SQLQuery.ReadOnly:=true;

rturney

  • New Member
  • *
  • Posts: 48
MySQL50 - newbie problem (Windows)
« Reply #18 on: May 07, 2007, 05:58:24 pm »
Bram,

Thanks for the clarification on SQLQuery.Open and .ExecSQL.  Just out of curiosity are you able to run the Lazarus MySQL tutorial?  I have run into many problems with it and am wondering if it is broken or I'm just going crazy?

arwen

  • Full Member
  • ***
  • Posts: 104
    • http://www.flussiliberi.it/
MySQL50 - newbie problem (Windows)
« Reply #19 on: May 07, 2007, 06:05:29 pm »
Quote
Note: SQLQuery.ExecSQL does not create a result set, whereas SQLQuery.Open does.

For a query like SHOW DATABASES, it is best to set

Code: [Select]
SQLQuery.ParseSQL:=false;
SQLQuery.ReadOnly:=true;



 :D THANKS bram now WORKS :D

 

TinyPortal © 2005-2018