Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-05

Need some help with UpdateSQL in TSQLQuery and TMySQL50Connection

17 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Howard Lee Harkness

I'm having some trouble understanding the operation of the TSQLQuery. I'm using MySQL 5, TMySQL50Connection, and TSQLQuery.

Several problems. First of all, it's not clear to me how the transaction component is to be hooked up. There is a property for that in both the connection component and the query component -- do these need to be separate components, or can they be the same transaction?

I'm also getting some errors on updates. I have been unable to locate any documentation or examples that relate to the relative simple task I wish to accomplish, so I figure the best way to get the information is to put together a really simple example, and see if I can find somebody to tell me what it wrong with it. Once I get it figured out, I'll be happy to write up the missing documentation and submit it to wherever it needs to go.

To start with, here's a sample database setup:

CREATE TABLE IF NOT EXISTS ZIPCODE
(
ZIPID INT NOT NULL AUTO_INCREMENT,
ZIP VARCHAR(5) NOT NULL,
ZIPEXT VARCHAR(4),
CITY VARCHAR(40),
STATE VARCHAR(2),
PRIMARY KEY(ZIPID)
);

INSERT INTO ZIPCODE (ZIP,ZIPEXT,CITY,STATE) VALUES ('01814',NULL,'Lawrence','MA')
,('13502',NULL,'Utica','NY')
,('22030',NULL,'Fairfax','VA')
,('27030',NULL,'Mt. Airy','NC')
,('27103',NULL,'Winston-Salem','NC')
,('27104',NULL,'Winston-salem','NC')
,('27106',NULL,'Winston-Salem','NC')

I started up Lazarus, created an application, and put a DBGrid, DBNavigator, a MySQL50Connection, an SQLTransaction, an SQLQuery, and a DataSource components on it. Here is the Form File:

object Form1: TForm1
Left = 307
Height = 300
Top = 180
Width = 602
HorzScrollBar.Page = 601
VertScrollBar.Page = 299
ActiveControl = DBGrid1
Caption = 'Form1'
ClientHeight = 300
ClientWidth = 602
Position = poDesktopCenter
object DBGrid1: TDBGrid
Left = 24
Height = 201
Top = 32
Width = 560
DataSource = Datasource1
FixedColor = clBtnFace
FixedHotColor = cl3DLight
Options = [dgEditing, dgTitles, dgIndicator, dgColumnResize, dgColumnMove, dgColLines, dgRowLines, dgTabs, dgAlwaysShowSelection, dgConfirmDelete, dgCancelOnExit]
OptionsExtra = [dgeAutoColumns, dgeCheckboxColumn] ParentColor = False
TabOrder = 0
TabStop = True

  end
  object DBNavigator1: TDBNavigator
    Left = 152
    Height = 25
    Top = 248
    Width = 241
    BevelOuter = bvNone
    ClientHeight = 25
    ClientWidth = 241
    DataSource = Datasource1
  end
  object MySQL50Connection1: TMySQL50Connection
    Connected = True
    Streamedconnected = True
    DatabaseName = 'test'
    Password = 'test'
    Transaction = SQLTransaction1
    UserName = 'root'
    left = 24
    top = 9
  end
  object SQLQuery1: TSQLQuery
    Active = True
    Database = MySQL50Connection1
    Transaction = SQLTransaction1
    SQL.Strings = (
      'select * from zipcode'
      'order by zip'
    )
    Params =
    UpdateMode = upWhereChanged
    UsePrimaryKeyAsKey = True
    ParseSQL = True
    left = 24
    top = 44
  end
  object SQLTransaction1: TSQLTransaction
    Database = MySQL50Connection1
    left = 59
    top = 9
  end
  object Datasource1: TDatasource
    DataSet = SQLQuery1
    left = 59
    top = 44
  end

end

I did not add any code at all to the main PAS file, so the project and source are as follows:

program zipcode;
{$mode objfpc}{$H+}
uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Interfaces, // this includes the LCL widgetset
  Forms
  { you can add units after this }, zipcode, SQLDBLaz;
begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

+++++

unit Zipcode;
{$mode objfpc}{$H+}
interface

uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,

  mysql50conn, sqldb, db, DBGrids, DbCtrls;
type
  { TForm1 }
  TForm1 = class(TForm)
    Datasource1: TDatasource;
    DBGrid1: TDBGrid;
    DBNavigator1: TDBNavigator;
    MySQL50Connection1: TMySQL50Connection;
    SQLQuery1: TSQLQuery;
    SQLTransaction1: TSQLTransaction;
  private
    { private declarations }
  public
    { public declarations }
  end;
var
  Form1: TForm1;
implementation
initialization
  {$I zipcode.lrs}
end.

Ok, if I run this as-is, I get some interesting errors. First thing I noticed is that when I click on "add" in the DBNavigator, the auto-increment field is not added properly; it's left blank.

Next, when I exit the program, I get a mysterious error message that tells me that I attempted to use a type name as an expression, as reported by procedure DatabaseError in unit db. I get a database error from just loading the program into Lazarus, and then closing Lazarus.

I'm suspecting the fixes for these problems will go a long way towards giving me an understanding of when and how to hook up the transaction components, and just what the parseSQL property is used for. And I'm suspecting that the fixes are very close to being trivial, but I've already spent too much time trying to help by letting me know what I am leaving out and/or doing wrong.

TIA

Howard Lee Harkness The Celtic Fiddler www.celtic-fiddler.com

Reply by email

Joost van der Sluis
to Howard Lee Harkness

Op maandag 26-05-2008 om 16:47 uur [tijdzone -0500], schreef Howard Lee Harkness:

Ok, if I run this as-is, I get some interesting errors. First thing I noticed is that when I click on "add" in the DBNavigator, the auto-increment field is not added properly; it's left blank.

That's normal. TSQLQuery caches everything. In fact the record isn't made yet, only in memory. So MySQL didn't generate a number yet.

Next, when I exit the program, I get a mysterious error message that tells me that I attempted to use a type name as an expression, as reported by procedure DatabaseError in unit db. I get a database error from just loading the program into Lazarus, and then closing Lazarus.

Can you give the literal error-message?

btw: you can use the same transaction for the query and the connection. Especially with MySQL, where the transaction-code only contains empty stubs.

Joost.

Reply by email

Howard Lee Harkness
to Joost van der Sluis

Replies below.

Joost van der Sluis wrote 8 lines
Op maandag 26-05-2008 om 16:47 uur [tijdzone -0500], schreef Howard Lee Harkness: > Ok, if I run this as-is, I get some interesting errors. First thing I > noticed is that when I click on "add" in the DBNavigator, the > auto-increment field is not added properly; it's left blank. That's normal. TSQLQuery caches everything. In fact the record isn't made yet, only in memory. So MySQL didn't generate a number yet.

When I click on "post", there is no ZIPID generated, and while the record looks like it got added, when I exit and restart the program, I see that nothing actually got inserted. I have to conclude that I'm leaving out something (probably a "commit"). I also see that deletes don't actually happen, probably for the same reason, and the 'post' doesn't generate a 'commit'.

If I recall correctly, back in the days of D3, using BDE, I could create a simple table editor with a dbgrid, a datasource, and a ttable (or tquery), and no added does not seem to be the case here, unless I connected a property up incorrectly.

Show quoted text 6 lines
> Next, when I exit the program, I get a mysterious error message that > tells me that I attempted to use a type name as an expression, as > reported by procedure DatabaseError in unit db. I get a database error > from just loading the program into Lazarus, and then closing Lazarus. Can you give the literal error-message?

Certainly. The error message I get on exit from Lazarus is: An exception occurred during deletion of
"SQLTransaction1:TSQLTransaction" Operation cannot be performed on an active dataset.

I do not get this error when running the program outside the IDE.

The error message I get when exiting the program (in the IDE only) is: Project rasised exception class 'EDatabaseError'

On examination of the msg parameter of Procedure DatabaseError (Const Msg:String), it reads: Attempt to use a type name as an expression.

Again, I do not see this exception when running the program outside of the IDE, so I am assuming this is an artifact of the debugger or IDE.

btw: you can use the same transaction for the query and the connection. Especially with MySQL, where the transaction-code only contains empty stubs.

Ok, that's good to know. Where/how do I invoke "commit" ?

Joost.
Howard Lee Harkness The Celtic Fiddler www.celtic-fiddler.com

Reply by email

Luca Olivetti
to Howard Lee Harkness

Howard Lee Harkness escribi?:

If I recall correctly, back in the days of D3, using BDE, I could create a simple table editor with a dbgrid, a datasource, and a ttable (or tquery), and no added does not seem to be the case here, unless I connected a property up incorrectly.

That's also the way zeos works under lazarus.

Bye

Luca Olivetti Wetron Automatizaci?n S.A. http://www.wetron.es/ Tel. +34 93 5883004 Fax +34 93 5883007

Reply by email

Joost van der Sluis
to Howard Lee Harkness: Replies below. When I click on "post", there is no ZIPID generated, and while the record…

Op maandag 26-05-2008 om 18:59 uur [tijdzone -0500], schreef Howard Lee Harkness:

Show quoted text 18 lines
Replies below. On Mon, May 26, 2008 at 5:04 PM, Joost van der Sluis wrote: > Op maandag 26-05-2008 om 16:47 uur [tijdzone -0500], schreef Howard Lee > Harkness: >> Ok, if I run this as-is, I get some interesting errors. First thing I >> noticed is that when I click on "add" in the DBNavigator, the >> auto-increment field is not added properly; it's left blank. > > That's normal. TSQLQuery caches everything. In fact the record isn't > made yet, only in memory. So MySQL didn't generate a number yet. When I click on "post", there is no ZIPID generated, and while the record looks like it got added, when I exit and restart the program, I see that nothing actually got inserted. I have to conclude that I'm leaving out something (probably a "commit"). I also see that deletes don't actually happen, probably for the same reason, and the 'post' doesn't generate a 'commit'.

That's true. You have to call 'TSQLQuery.ApplyUpdates' Then all changes in the local, in-memory changes-buffer are converted into update/insert/delete statements and executed on the underlying database.

For those connections that do support transactions, you also have to do
TSQLTransaction.Commit(Retaining).
Show quoted text 13 lines
>> Next, when I exit the program, I get a mysterious error message that >> tells me that I attempted to use a type name as an expression, as >> reported by procedure DatabaseError in unit db. I get a database error >> from just loading the program into Lazarus, and then closing Lazarus. > > Can you give the literal error-message? Certainly. The error message I get on exit from Lazarus is: An exception occurred during deletion of "SQLTransaction1:TSQLTransaction" Operation cannot be performed on an active dataset. I do not get this error when running the program outside the IDE.

Then this exception is catched by an try-except statement. But the IDE/Debugger can't detect that. Probably nothing to worry about. But you can check if the order in which dataset/transaction etc are closed are in order.

Joost.

Reply by email

Howard Lee Harkness
to Luca Olivetti: Howard Lee Harkness escribi?: That's also the way zeos works under lazarus. Bye Luca…

Interesting. I will have to give Zeos a look-see. Meanwhile, I located a tutorial on SQLite that does about 70% of what I had in mind in the first place.

However, even though MySQL is overkill for my current project, I will probably continue with it, and contribute some of the missing documentation when I get done. I'm assuming that Zeos works with MySQL. MySQL looks like a very capable database with most of the features that I am familiar with from other environments, and despite complaints that I have seen, it appears to be plenty fast enough.

Sent from my iPhone (please excuse typos)
Howard Lee Harkness
The Celtic Fiddler
www.celtic-fiddler.com

Luca Olivetti wrote 19 lines
Howard Lee Harkness escribi?: > If I recall correctly, back in the days of D3, using BDE, I could > create a simple table editor with a dbgrid, a datasource, and a > ttable > (or tquery), and no added does not seem to be the > case here, unless I connected a property up incorrectly. That's also the way zeos works under lazarus. Bye -- Luca Olivetti Wetron Automatizaci?n S.A. http://www.wetron.es/ Tel. +34 93 5883004 Fax +34 93 5883007 _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Howard Lee Harkness
to Joost van der Sluis: Op maandag 26-05-2008 om 18:59 uur [tijdzone -0500], schreef Howard Lee Harkness: That's…

Ok, I tried calling ApplyUpdates, and I did not detect any difference. Could you perhaps show me in the code below exactly WHERE I need to call ApplyUpdates?

Joost van der Sluis wrote 7 lines
That's true. You have to call 'TSQLQuery.ApplyUpdates' Then all changes in the local, in-memory changes-buffer are converted into update/insert/delete statements and executed on the underlying database. For those connections that do support transactions, you also have to do TSQLTransaction.Commit(Retaining).
unit Zipcode;
{$mode objfpc}{$H+}
interface

uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, mysql50conn, sqldb, db, DBGrids, DbCtrls;

type
 { TForm1 }
 TForm1 = class(TForm)
   Datasource1: TDatasource;
   DBGrid1: TDBGrid;
   DBNavigator1: TDBNavigator;
   MySQL50Connection1: TMySQL50Connection;
   SQLQuery1: TSQLQuery;
   SQLTransaction1: TSQLTransaction;
 private
   { private declarations }
 public
   { public declarations }
 end;
var
 Form1: TForm1;
implementation
initialization
 {$I zipcode.lrs}
end.
Howard Lee Harkness -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080614/47ff981c/attachment-0001.html

Reply by email

Howard Lee Harkness
to Howard Lee Harkness

I was able to get the Insert and Refresh buttons to work with code like this:

case Button of
 nbPost: SQLQuery1.Applyupdates;
 nbRefresh: begin SQLQuery1.Close; SQLQuery1.Open; end;
...
end;

However, it doesn't seem to matter what I put in for nbDelete. I always get the error "There are no fields found to generate the where-clause" if I do ApplyUpdates for nbDelete. If I put nothing in there, the field appears to be deleted, but it is still in the table, and comes back to the grid when I press "refresh".

On Sat, Jun 14, 2008 at 3:22 PM, Howard Lee Harkness <

Show quoted text 57 lines
wrote: Ok, I tried calling ApplyUpdates, and I did not detect any difference. Could you perhaps show me in the code below exactly WHERE I need to call ApplyUpdates? On Tue, May 27, 2008 at 5:00 AM, Joost van der Sluis wrote: > That's true. You have to call 'TSQLQuery.ApplyUpdates' Then all changes > in the local, in-memory changes-buffer are converted into > update/insert/delete statements and executed on the underlying database. > > For those connections that do support transactions, you also have to do > TSQLTransaction.Commit(Retaining). > unit Zipcode; {$mode objfpc}{$H+} interface uses Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, mysql50conn, sqldb, db, DBGrids, DbCtrls; type { TForm1 } TForm1 = class(TForm) Datasource1: TDatasource; DBGrid1: TDBGrid; DBNavigator1: TDBNavigator; MySQL50Connection1: TMySQL50Connection; SQLQuery1: TSQLQuery; SQLTransaction1: TSQLTransaction; private { private declarations } public { public declarations } end; var Form1: TForm1; implementation initialization {$I zipcode.lrs} end. -- Howard Lee Harkness
Howard Lee Harkness -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080614/0cf6d5aa/attachment.html

Reply by email

Joost van der Sluis
to Howard Lee Harkness

Op zaterdag 14-06-2008 om 16:06 uur [tijdzone -0500], schreef Howard Lee Harkness:

Show quoted text 5 lines
However, it doesn't seem to matter what I put in for nbDelete. I always get the error "There are no fields found to generate the where-clause" if I do ApplyUpdates for nbDelete. If I put nothing in there, the field appears to be deleted, but it is still in the table, and comes back to the grid when I press "refresh".

Does your table has a primary key? And do you have set the 'UsePrimaryKeyAsKey' property to true?

sqldb tries to create an delete-query for you, but to do that it has to indentify the record that should be deleted. Normally it uses the primary key for that. If there is no primary key, you have to tell it which fields should be included as a 'key'. (ie: be a part of the where-statement in the delete query: 'delect from table where ...)

Joost.

Reply by email

Howard Lee Harkness
to Joost van der Sluis
Joost van der Sluis wrote 11 lines
Op zaterdag 14-06-2008 om 16:06 uur [tijdzone -0500], schreef Howard Lee Harkness: > However, it doesn't seem to matter what I put in for nbDelete. I > always get the error "There are no fields found to generate the > where-clause" if I do ApplyUpdates for nbDelete. If I put nothing in > there, the field appears to be deleted, but it is still in the table, > and comes back to the grid when I press "refresh". Does your table has a primary key? And do you have set the 'UsePrimaryKeyAsKey' property to true?

Yes, and yes. See the code that I posted at the beginning of the thread -- if you see a problem with the code , please tell me what I'm doing wrong, or not doing right. There is definitely something wrong with it, because it doesn't work. If I left something out, tell me and I can just zip up the whole project and email it to you.

Show quoted text 7 lines
sqldb tries to create an delete-query for you, but to do that it has to indentify the record that should be deleted. Normally it uses the primary key for that. If there is no primary key, you have to tell it which fields should be included as a 'key'. (ie: be a part of the where-statement in the delete query: 'delect from table where ...)

Things would be a lot easier for me if only I could find a working example of a small database program using MySQL and Lazarus. I've found a few examples, but I have been unable to make any of them work. Currently, I'm about to download the latest Lazarus/FPC versions to see if something magically works, but it seems to me that I really ought be able to get a trivial program like the one I posted at the beginning of the thread to work with minimal effort.

Here again is the code that I posted in the first part of the thread:

To start with, here's a sample database setup:

CREATE TABLE IF NOT EXISTS ZIPCODE
(
ZIPID INT NOT NULL AUTO_INCREMENT,
ZIP VARCHAR(5) NOT NULL,
ZIPEXT VARCHAR(4),
CITY VARCHAR(40),
STATE VARCHAR(2),
PRIMARY KEY(ZIPID) -- YES! there is a primary key! );

INSERT INTO ZIPCODE (ZIP,ZIPEXT,CITY,STATE) VALUES ('01814',NULL,'Lawrence','MA')
,('13502',NULL,'Utica','NY')
,('22030',NULL,'Fairfax','VA')
,('27030',NULL,'Mt. Airy','NC')
,('27103',NULL,'Winston-Salem','NC')
,('27104',NULL,'Winston-salem','NC')
,('27106',NULL,'Winston-Salem','NC')

I started up Lazarus, created an application, and put a DBGrid, DBNavigator, a MySQL50Connection, an SQLTransaction, an SQLQuery, and a DataSource components on it. Here is the Form File:

object Form1: TForm1
Left = 307
Height = 300
Top = 180
Width = 602
HorzScrollBar.Page = 601
VertScrollBar.Page = 299
ActiveControl = DBGrid1
Caption = 'Form1'
ClientHeight = 300
ClientWidth = 602
Position = poDesktopCenter
object DBGrid1: TDBGrid
Left = 24
Height = 201
Top = 32
Width = 560
DataSource = Datasource1
FixedColor = clBtnFace
FixedHotColor = cl3DLight
Options = [dgEditing, dgTitles, dgIndicator, dgColumnResize, dgColumnMove, dgColLines, dgRowLines, dgTabs, dgAlwaysShowSelection, dgConfirmDelete, dgCancelOnExit]
OptionsExtra = [dgeAutoColumns, dgeCheckboxColumn] ParentColor = False
TabOrder = 0
TabStop = True
end
object DBNavigator1: TDBNavigator
Left = 152
Height = 25
Top = 248
Width = 241
BevelOuter = bvNone
ClientHeight = 25
ClientWidth = 241
DataSource = Datasource1
end
object MySQL50Connection1: TMySQL50Connection
Connected = True
Streamedconnected = True
DatabaseName = 'test'
Password = 'test'
Transaction = SQLTransaction1
UserName = 'root'
left = 24
top = 9
end
object SQLQuery1: TSQLQuery
Active = True
Database = MySQL50Connection1
Transaction = SQLTransaction1
SQL.Strings = (
'select * from zipcode'
'order by zip'
)
Params =
UpdateMode = upWhereChanged
UsePrimaryKeyAsKey = True // YES! UsePrimaryKeyAsKey is set to True!
ParseSQL = True
left = 24
top = 44
end
object SQLTransaction1: TSQLTransaction
Database = MySQL50Connection1
left = 59
top = 9
end
object Datasource1: TDatasource
DataSet = SQLQuery1
left = 59
top = 44
end
end

I did not add any code at all to the main PAS file, so the project and source are as follows:

program zipcode;
{$mode objfpc}{$H+}
uses
 {$IFDEF UNIX}{$IFDEF UseCThreads}
 cthreads,
 {$ENDIF}{$ENDIF}
 Interfaces, // this includes the LCL widgetset
 Forms
 { you can add units after this }, zipcode, SQLDBLaz;
begin
 Application.Initialize;
 Application.CreateForm(TForm1, Form1);
 Application.Run;
end.

+++++

unit Zipcode;
{$mode objfpc}{$H+}
interface

uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, mysql50conn, sqldb, db, DBGrids, DbCtrls;

type
 { TForm1 }
 TForm1 = class(TForm)
   Datasource1: TDatasource;
   DBGrid1: TDBGrid;
   DBNavigator1: TDBNavigator;
   MySQL50Connection1: TMySQL50Connection;
   SQLQuery1: TSQLQuery;
   SQLTransaction1: TSQLTransaction;
 private
   { private declarations }
 public
   { public declarations }
 end;
var
 Form1: TForm1;
implementation
initialization
 {$I zipcode.lrs}
end.

BTW, I did get rid of the exception on close by adding an event handler for formclose that closes the database. And I was able to get an insert to work by adding an event handler to the navigator component that did SQLQuery1.Appyupdates in response to nbPost button click. However, delete and edit still do not work.

Howard Lee Harkness www.celtic-fiddler.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080621/5ca7f698/attachment.html

Reply by email

Joost van der Sluis
to Howard Lee Harkness

Op zaterdag 21-06-2008 om 14:04 uur [tijdzone -0500], schreef Howard Lee Harkness:

Show quoted text 22 lines
On Thu, Jun 19, 2008 at 8:22 AM, Joost van der Sluis wrote: Op zaterdag 14-06-2008 om 16:06 uur [tijdzone -0500], schreef Howard Lee Harkness: > However, it doesn't seem to matter what I put in for nbDelete. I > always get the error "There are no fields found to generate the > where-clause" if I do ApplyUpdates for nbDelete. If I put nothing in > there, the field appears to be deleted, but it is still in the table, > and comes back to the grid when I press "refresh". Yes, and yes. See the code that I posted at the beginning of the thread -- if you see a problem with the code , please tell me what I'm doing wrong, or not doing right. There is definitely something wrong with it, because it doesn't work. If I left something out, tell me and I can just zip up the whole project and email it to you.

Sorry, but with the code you've sent, it's truely impossible to get the error-message you claim that you got. There even is no 'ApplyUpdates' in your code. That code is completely irrelevent - it's the code of an empy program.

Please, don't send puzzles to us, we can't help you if you do.

For an example look at the fpc-code: packages/fcl-db/sqldb/examples

Joost.

Reply by email

Joost van der Sluis
to Joost van der Sluis

You can disregard this mail, in the mean time most issues are cleared out. ;)

Joost.

Op zondag 22-06-2008 om 15:48 uur [tijdzone +0200], schreef Joost van der Sluis:

Show quoted text 42 lines
Op zaterdag 21-06-2008 om 14:04 uur [tijdzone -0500], schreef Howard Lee Harkness: > On Thu, Jun 19, 2008 at 8:22 AM, Joost van der Sluis > wrote: > Op zaterdag 14-06-2008 om 16:06 uur [tijdzone -0500], schreef > Howard Lee > Harkness: > > > However, it doesn't seem to matter what I put in for > nbDelete. I > > always get the error "There are no fields found to generate > the > > where-clause" if I do ApplyUpdates for nbDelete. If I put > nothing in > > there, the field appears to be deleted, but it is still in > the table, > > and comes back to the grid when I press "refresh". > > Yes, and yes. See the code that I posted at the beginning of the > thread -- if you see a problem with the code , please tell me what I'm > doing wrong, or not doing right. There is definitely something wrong > with it, because it doesn't work. If I left something out, tell me and > I can just zip up the whole project and email it to you. Sorry, but with the code you've sent, it's truely impossible to get the error-message you claim that you got. There even is no 'ApplyUpdates' in your code. That code is completely irrelevent - it's the code of an empy program. Please, don't send puzzles to us, we can't help you if you do. For an example look at the fpc-code: packages/fcl-db/sqldb/examples Joost. _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Howard Lee Harkness
to Joost van der Sluis: Op zaterdag 21-06-2008 om 14:04 uur [tijdzone -0500], schreef Howard Lee Harkness: Sorry,…

After several rounds of non-answers here (seems the developers just assume everybody else should know the internals of everything, which is not realistic), a member of the Lazarus forum posted the answer to this problem. The ApplyUpdates call can be placed in the "after" event handlers. Fairly simple, and in retrospect, fairly obvious.

Knowing that two months ago would have saved me a lot of time. Meanwhile, I switched to PostgreSQL, and the components for that DB don't appear to have the same problem.

Joost van der Sluis wrote 42 lines
Op zaterdag 21-06-2008 om 14:04 uur [tijdzone -0500], schreef Howard Lee Harkness: > On Thu, Jun 19, 2008 at 8:22 AM, Joost van der Sluis > wrote: > Op zaterdag 14-06-2008 om 16:06 uur [tijdzone -0500], schreef > Howard Lee > Harkness: > > > However, it doesn't seem to matter what I put in for > nbDelete. I > > always get the error "There are no fields found to generate > the > > where-clause" if I do ApplyUpdates for nbDelete. If I put > nothing in > > there, the field appears to be deleted, but it is still in > the table, > > and comes back to the grid when I press "refresh". > > Yes, and yes. See the code that I posted at the beginning of the > thread -- if you see a problem with the code , please tell me what I'm > doing wrong, or not doing right. There is definitely something wrong > with it, because it doesn't work. If I left something out, tell me and > I can just zip up the whole project and email it to you. Sorry, but with the code you've sent, it's truely impossible to get the error-message you claim that you got. There even is no 'ApplyUpdates' in your code. That code is completely irrelevent - it's the code of an empy program. Please, don't send puzzles to us, we can't help you if you do. For an example look at the fpc-code: packages/fcl-db/sqldb/examples Joost. _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Howard Lee Harkness -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080828/423c5ad2/attachment.html

Reply by email

Joost van der Sluis
to Howard Lee Harkness

Op donderdag 28-08-2008 om 15:21 uur [tijdzone -0500], schreef Howard Lee Harkness:

After several rounds of non-answers here (seems the developers just assume everybody else should know the internals of everything, which is not realistic),

Assuming that we can understand your problem without knowing the internals of what you're doing is also not realistic. As I tried to explain to you, I coudn't figure out what you were trying to do, and how you tried it. In that case: we can't help you.

a member of the Lazarus forum posted the answer to this problem. The ApplyUpdates call can be placed in the "after" event handlers. Fairly simple, and in retrospect, fairly obvious.

So now I understand what your problem is: actually it's not a problem with applyUpdates, but you want that it's called 'automagically'.

I think you'd better place the ApplyUpdates in the after-scroll event, in that case. That's much easier. But your approach will also work.

Knowing that two months ago would have saved me a lot of time.

This could also help: http://www.catb.org/~esr/faqs/smart-questions.html

Meanwhile, I switched to PostgreSQL, and the components for that DB don't appear to have the same problem.

That's always a good idea. ;)

Joost.

Reply by email

Howard Lee Harkness
to Joost van der Sluis
Joost van der Sluis wrote 7 lines
So now I understand what your problem is: actually it's not a problem with applyUpdates, but you want that it's called 'automagically'. I think you'd better place the ApplyUpdates in the after-scroll event, in that case. That's much easier. But your approach will also work.

Actually, I asked more than once (trying to phrase it differently each time) "Where does the call to ApplyUpdates need to be?" and got similar non-answers each time. But life goes on, and the PostgreSQL components appear to do mostly what I had in mind.

If I should ever find time, I might look into why the MySQL components didn't. However, time is at a premium these days, and probably always will be. Once I finish this little side project, I will probably lose all interest in Lazarus/FPC/PostgreSQL/MySQL anyway, and concentrate on my day job as a high-performance graphics tools programmer using C++. The only reason I was ever interested in Lazarus is because Delphi was the fastest, easiest way I knew of to slap a GUI onto a trivial DB program (and the program I was trying to write should have been REALLY trivial), and I didn't have access to a copy of Delphi (too expensive for a one-off side project, anyway).

Howard Lee Harkness www.celtic-fiddler.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080829/1cef547a/attachment.html

Reply by email

Jesus Reyes
to Howard Lee Harkness: After several rounds of non-answers here (seems the developers just assume everybody else…

--- El jue 28-ago-08, Howard Lee Harkness escribi?:

Show quoted text 20 lines
De:: Howard Lee Harkness Asunto: Re: [Lazarus] Need some help with UpdateSQL in TSQLQuery and TMySQL50Connection A: "General mailing list" Fecha: jueves, 28 agosto, 2008, 3:21 pm After several rounds of non-answers here (seems the developers just assume everybody else should know the internals of everything, which is not realistic), a member of the Lazarus forum posted the answer to this problem. The ApplyUpdates call can be placed in the "after" event handlers. Fairly simple, and in retrospect, fairly obvious. Knowing that two months ago would have saved me a lot of time. Meanwhile, I switched to PostgreSQL, and the components for that DB don't appear to have the same problem.

Two months ago? it means you didn't read it:

http://article.gmane.org/gmane.comp.ide.lazarus.general/25599/match=advice+creating+database+aware+application+lazarus

Jesus Reyes A.

__________________________________________________ Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ?gratis! Reg?strate ya - http://correo.yahoo.com.mx/

Reply by email

Howard Lee Harkness
to Jesus Reyes

You are correct, I missed that one completely.

Jesus Reyes wrote 46 lines
--- El jue 28-ago-08, Howard Lee Harkness escribi?: > De:: Howard Lee Harkness > Asunto: Re: [Lazarus] Need some help with UpdateSQL in TSQLQuery and TMySQL50Connection > A: "General mailing list" > Fecha: jueves, 28 agosto, 2008, 3:21 pm > After several rounds of non-answers here (seems the > developers just assume > everybody else should know the internals of everything, > which is not > realistic), a member of the Lazarus forum posted the answer > to this problem. > The ApplyUpdates call can be placed in the > "after" event handlers. Fairly > simple, and in retrospect, fairly obvious. > > Knowing that two months ago would have saved me a lot of > time. Meanwhile, I > switched to PostgreSQL, and the components for that DB > don't appear to have > the same problem. > Two months ago? it means you didn't read it: http://article.gmane.org/gmane.comp.ide.lazarus.general/25599/match=advice+creating+database+aware+application+lazarus Jesus Reyes A. __________________________________________________ Correo Yahoo! Espacio para todos tus mensajes, antivirus y antispam ?gratis! Reg?strate ya - http://correo.yahoo.com.mx/ _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Howard Lee Harkness -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080830/277cb475/attachment.html

Reply by email