Re: [lazarus] SQLite 3 -- Capture FieldValues into a variable

2007-11-27 Thread Joost van der Sluis
Op maandag 26-11-2007 om 23:50 uur [tijdzone +0100], schreef Joost van
der Sluis:
 Op maandag 26-11-2007 om 15:05 uur [tijdzone +0100], schreef Roberto
 Padovani:
  2007/11/26, Daniel Rincón García [EMAIL PROTECTED]:
  To the Great Guys of the lazarus project:
  
  I am finishing a medium size project with lazarus + sqlite3, for which
  I had study and experiment a lot due to the fact that, IMHO, the
  database tutorial was slightly too quick on the sqlite part.
  Would you appreciate it if I wrote a tutorial (= commented example) on
  sqlite3 with basic topics like the one above and the not so trivial
  date management stuff ?
  If you don't really care about it, I won't spend time on it; but if
  you do care, please point me to the instructions for the wiki and/or a
  tutorial page templatethis will be my Christmas present to the
  Lazarus project. :-)
 
 The database-documentation is as good as non-existent. All examples and
 tutorials are usefull. So please do.

For those who are worried now: the documentation and examples of most
other TDataset-based components which can be found all over the net,
books etc. do basically also apply to fcl-db. It could be that you need
some slight adjustions, but the ideas behind it all are the same.

Joost

_
 To unsubscribe: mail [EMAIL PROTECTED] with
unsubscribe as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


[lazarus] SQLite 3 -- Capture FieldValues into a variable

2007-11-26 Thread Daniel Rincón García
Hi, I need to capture the FieldValues of a SQLite database into a string
variable.

If I do it:

   while not dsTest.EOF do
begin
 DataToSend := DataToSend +
dsTest.FieldValues['Code'] + '\' +
dsTest.FieldValues['Name'] + '\' +
dsTest.FieldValues['Address'] + '#';
 dsTest.Next;
end;

I have got the next error message:

Project raised exception class 'RunError(231)'.

If I do it then works:

   while not dsTest.EOF do
begin
 Cod := dsTest.FieldValues['Code'];
 Nam := dsTest.FieldValues['Name'];
 Addr := dsTest.FieldValues['Address'];
 DataToSend := DataToSend + Cod + '\' + Nam + '\' + Addr + '#';
 dsTest.Next;
end;

But I have to declare three string variables (Cod, Nam and Addr).

Can you help me?


Re: [lazarus] SQLite 3 -- Capture FieldValues into a variable

2007-11-26 Thread Roberto Padovani
2007/11/26, Daniel Rincón García [EMAIL PROTECTED]:
 Hi, I need to capture the FieldValues of a SQLite database into a string
 variable.

 If I do it:

while not dsTest.EOF do
  begin
  DataToSend := DataToSend +
 dsTest.FieldValues ['Code'] + '\' +
 dsTest.FieldValues['Name'] + '\' +
  dsTest.FieldValues['Address'] + '#';


provided that DataToSend is a string (as I suppose), you should do this:

DataToSend := DataToSend + dsTest.FieldByName('Code').AsString;

since FieldByName() returns a TField, have a look at the other methods
for type casting.
There is basically everything: AsInteger, AsBoolean, and so on..
This also explains why your second code happened to work.

Now I'll break every netiquette rule and change (partially) subject:

To the Great Guys of the lazarus project:

I am finishing a medium size project with lazarus + sqlite3, for which
I had study and experiment a lot due to the fact that, IMHO, the
database tutorial was slightly too quick on the sqlite part.
Would you appreciate it if I wrote a tutorial (= commented example) on
sqlite3 with basic topics like the one above and the not so trivial
date management stuff ?
If you don't really care about it, I won't spend time on it; but if
you do care, please point me to the instructions for the wiki and/or a
tutorial page templatethis will be my Christmas present to the
Lazarus project. :-)

Roberto

_
 To unsubscribe: mail [EMAIL PROTECTED] with
unsubscribe as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] SQLite 3 -- Capture FieldValues into a variable

2007-11-26 Thread willem

Roberto Padovani wrote:

2007/11/26, Daniel Rincón García [EMAIL PROTECTED]:
  

Hi, I need to capture the FieldValues of a SQLite database into a string
variable.

If I do it:

   while not dsTest.EOF do
 begin
 DataToSend := DataToSend +
dsTest.FieldValues ['Code'] + '\' +
dsTest.FieldValues['Name'] + '\' +
 dsTest.FieldValues['Address'] + '#';




provided that DataToSend is a string (as I suppose), you should do this:

DataToSend := DataToSend + dsTest.FieldByName('Code').AsString;

since FieldByName() returns a TField, have a look at the other methods
for type casting.
There is basically everything: AsInteger, AsBoolean, and so on..
This also explains why your second code happened to work.

Now I'll break every netiquette rule and change (partially) subject:

To the Great Guys of the lazarus project:

I am finishing a medium size project with lazarus + sqlite3, for which
I had study and experiment a lot due to the fact that, IMHO, the
database tutorial was slightly too quick on the sqlite part.
Would you appreciate it if I wrote a tutorial (= commented example) on
sqlite3 with basic topics like the one above and the not so trivial
date management stuff ?
If you don't really care about it, I won't spend time on it; but if
you do care, please point me to the instructions for the wiki and/or a
tutorial page templatethis will be my Christmas present to the
Lazarus project. :-)

Roberto

  

See : http://nl.wikipedia.org/wiki/Free_Pascal

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] SQLite 3 -- Capture FieldValues into a variable

2007-11-26 Thread John




Daniel Rincn Garca wrote:
Hi, I need to capture the FieldValues of a SQLite database
into a string variable.
  
If I do it:
  
   while not dsTest.EOF do
   begin
   DataToSend := DataToSend + 
  
dsTest.FieldValues
['Code'] + '\' +
  
dsTest.FieldValues['Name'] + '\' + 
  
dsTest.FieldValues['Address'] + '#';
   dsTest.Next;
   end; 
  
I have got the next error message:
  
  Project raised exception class
'RunError(231)'.
  
If I do it then works:
  
   while not dsTest.EOF do
   begin
   Cod :=
dsTest.FieldValues['Code'];
  
   Nam :=
dsTest.FieldValues['Name'];
   Addr :=
dsTest.FieldValues['Address'];
  
   DataToSend := DataToSend + Cod
+ '\' + Nam + '\' + Addr + '#';
   dsTest.Next;
   end; 
  
But I have to declare three string variables (Cod, Nam and Addr).
  
Can you help me?

I'm not sure, but it is probably because FieldValues returns a
variant. Try using
FieldByName[...].AsString:
 
DataToSend := DataToSend + 

dsTest.FieldByName
['Code'].AsString + '\' +

dsTest.FieldByName['Name'].AsString + '\' + 

 dsTest.FieldByName['Address'].AsString + '#';

Cheers,
John Sunderland





_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] SQLite 3 -- Capture FieldValues into a variable

2007-11-26 Thread Joost van der Sluis
Op maandag 26-11-2007 om 13:17 uur [tijdzone +0100], schreef Daniel
Rincón García:
 Hi, I need to capture the FieldValues of a SQLite database into a
 string variable.
 
 If I do it:
 
while not dsTest.EOF do
 begin
  DataToSend := DataToSend + 
 dsTest.FieldValues ['Code'] + '\' +
 dsTest.FieldValues['Name'] + '\' + 
 dsTest.FieldValues['Address'] + '#';
  dsTest.Next;
 end;
 
 I have got the next error message:
 
 Project raised exception class 'RunError(231)'.

Use .asstring as mentioned elsewhere, and submit a bug
(http:/www.freepascal.org/mantis, fpc-project) because what you do
shouldn't give this error.

Joost.

_
 To unsubscribe: mail [EMAIL PROTECTED] with
unsubscribe as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] SQLite 3 -- Capture FieldValues into a variable

2007-11-26 Thread Joost van der Sluis
Op maandag 26-11-2007 om 15:05 uur [tijdzone +0100], schreef Roberto
Padovani:
 2007/11/26, Daniel Rincón García [EMAIL PROTECTED]:
 To the Great Guys of the lazarus project:
 
 I am finishing a medium size project with lazarus + sqlite3, for which
 I had study and experiment a lot due to the fact that, IMHO, the
 database tutorial was slightly too quick on the sqlite part.
 Would you appreciate it if I wrote a tutorial (= commented example) on
 sqlite3 with basic topics like the one above and the not so trivial
 date management stuff ?
 If you don't really care about it, I won't spend time on it; but if
 you do care, please point me to the instructions for the wiki and/or a
 tutorial page templatethis will be my Christmas present to the
 Lazarus project. :-)

The database-documentation is as good as non-existent. All examples and
tutorials are usefull. So please do.

A few people send a mail to the fpc-pascal mailinglist about adding some
documentation about fcl-db.

Joost

_
 To unsubscribe: mail [EMAIL PROTECTED] with
unsubscribe as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives