[Lazarus] Postgres database again...
Dave Coventry
dgcoventry at gmail.com
Tue May 27 10:28:03 CEST 2008
Damien this is the code I'm using:
sqlq:='INSERT INTO registration
(enquiryreferencenumber,fname,sname,initials,id,titlecombobox,postaladdy,town,country,pcode,cell,email,emailtld,enquirydate)
';
sqlq:=sqlq+'VALUES
(nextval(''reg_seq''),'''+FName.Text+''','''+SName.Text+''','''+Initials.Text+''','''+ID.Text+''','''+TitleComboBox.Text+''','''+PostalAddy.Text+''','''+Town.Text+''','''+Country.Text+''','''+PCode.Text+''','''+Cell.Text+''','''+email.Text+''','''+emailTLD.Text+''','''+EnquiryDate.Text+''')';
PQConnection1.Connected:=True;
PQConnection1.ExecuteDirect('Begin Work;');
PQConnection1.ExecuteDirect(sqlq);
PQConnection1.ExecuteDirect('Commit Work;');
PQConnection1.Connected:=False;
SQLQuery1.SQL.Clear;
SQLQUery1.SQL.Append('SELECT enquiryreferencenumber FROM
registration WHERE fname = '''+FName.Text+''' AND sname = '''+
Sname.Text+''';');
SQLQuery1.Open;
enquiryreferencenumber.Text:=SQLQuery1.Fields[0].AsString;
SQLQuery1.Close;
The error I get is because SQLQuery1.Fields[0]. is out of range, so
there is nothing in SQLQuery1.Fields.
(I'm also, rather clumsily trying to access the last record using the
fname and sname; I would prefer to have a more reiable way of
retrieving it)
More information about the Lazarus
mailing list