As I was unable to work with mysql ... I am using an Access database (mdb), I connect via odbc component to ms access and I'm fetching the data from a table using TSQLQuery.
I'm using a dbgrid, and when I change the contents of a field in the dbgrid, I can not update the table in the database.
I've tried several examples I have seen on the net, but I can not make this to work ... I know I'm doing something wrong .. but do not know where ...
TSQLQuery useprimarykeyaskey=false since odbc component don´t work with this .
in TSQLQuery i have create the 4 parameters with the correct type , I had to put to false Paramcheck because it always give me 0 count heaven with the parameters created ... wtf ????
this is my TSQLQuery.UpdateSQL property "update emails set Numero=:Numero ,Nome=:Nome,email=:email where ID=:ID "
upda]"]>Blockedde property is set to upWhereKeyOnly
this is my events on the TSQLQuery (SQLQryEmails) .
procedure TDM.SQLQryEmailsAfterPost(DataSet: TDataSet);
var
cnt :Integer;
begin
cnt:=SQLQryEmails.Params.Count;
SQLQryEmails.ApplyUpdates();
end;
procedure TDM.SQLQryEmailsBeforePost(DataSet: TDataSet);
begin
SQLQryEmails.Params[0].AsInteger := DataSet.FieldByName('Numero').AsInteger;
SQLQryEmails.Params[1].AsString := DataSet.FieldByName('Nome').AsString;
SQLQryEmails.Params[2].AsString := DataSet.FieldByName('email').AsString;
SQLQryEmails.Params[3].AsInteger := DataSet.FieldByName('ID').AsInteger;
end;
procedure TDM.SQLQryEmailsAfterEdit(DataSet: TDataSet);
begin
SQLQryEmails.Params[0].AsInteger := DataSet.FieldByName('Numero').AsInteger;
SQLQryEmails.Params[1].AsString := DataSet.FieldByName('Nome').AsString;
SQLQryEmails.Params[2].AsString := DataSet.FieldByName('email').AsString;
SQLQryEmails.Params[3].AsInteger := DataSet.FieldByName('ID').AsInteger;
end;
note: already tried with SQLQryEmails.Params.ParamByName(....) , with same result .. none
none of this works ... I'm getting nuts with this ....