Bedankt voor het kijken!
Nee, ik gebruik niet embedded Firebird in de code. Dat zou wel kunnen - de tutorial laat de embedded client DLL fbembed.dll omnoemen naar de gewone Client/Server client fbclient.dll - maar ik heb de code er niet op aangepast.
Misschien werkt de code wel out of the box na een recente (laatste dag of 2) patch van FPC (als je hostname leeg laat), heb het nog niet getest.
Ik gebruik Lazarus 0.9.31, snapshot van 3 september, maar heb er ook met eerdere versies aan gewerkt.
Overigens heb ik nog zitten rommelen; helaas heeft dit:
Code:
SQLQuery1.SQL.Text := 'select * from CUSTOMER where COUNTRY = :COUNTRY';
SQLQuery1.Params.ParamByName('COUNTRY').AsString := Edit1.Text;
// We need a custom insert statement that ignores the primary key.
// The database will then generate an autonumber
// So we set up an SQL statement that inserts all fields except CUST_NO
// The parameters on the right (those beginning with :) must match
// the field names exactly for this to work.
// You might need to adapt this to your table schema if it is different.
SQLQuery1.InsertSQL.Text:=
'INSERT INTO CUSTOMER (CUSTOMER, CONTACT_FIRST, CONTACT_LAST, PHONE_NO, ADDRESS_LINE1, ADDRESS_LINE2, CITY, STATE_PROVINCE, COUNTRY, POSTAL_CODE, ON_HOLD) ' +
'VALUES (:CUSTOMER,:CONTACT_FIRST,:CONTACT_LAST,:PHONE_NO,:ADDRESS_LINE1,:ADDRESS_LINE2,:CITY,:STATE_PROVINCE,:COUNTRY,:POSTAL_CODE,:ON_HOLD);';
IBConnection1.Connected := True;
SQLTransaction1.Active := True; //Starts a new transaction
SQLQuery1.Open;
SQLQuery1.FieldByName('CUST_NO').ProviderFlags:=[pfInWhere,pfInKey]; //We leave out pfInUpdate
// Hide the primary key column which is the first column in our queries.
// We can only do this once the DBGrid has created the columns
DBGrid1.Columns[0].Visible:=false;
dezelfde foutmelding als resultaat: Lazarus wil nog steeds die primary key ingevoegd zien!?!?
Bookmarks