Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL + SAVE

Status
Not open for further replies.

gmie

Programmer
Sep 6, 2001
29
0
0
MY
Hello all...

I have a problem here related to database. I try to save data from form into MySQL. Here my code

procedure TForm1.Button1Click(Sender: TObject);
var
idid, addresss, dsql: string;
begin
idid := id.Text;
addresss := address.Text;
showmessage(idid);
showmessage(addresss);
dsql := 'insert into bidata (id, name) ';
dsql := dsql + 'values (';
dsql := dsql + '''' + idid + '''' + ', ';
dsql := dsql + '''' + addresss + '''' + ')';
quri.SQL.Add(dsql);
quri.ExecSQL;
datasource1.DataSet.Open;

end;

I use TQuery and T DataSource for this.

Error message is "BDEEngineError, error in SQL statement near insert in to........".

Can someone help on this...plz

TQ
 
Why don't you use the data-aware components like Tdbedit or others.
An other thing, kick out the dsql variable.
If you want to modify the query during runtime, call query.sql.clear first.

Use the query.sql.add('xxx') in little steps. Your problem has probably something to do with the sintaxe.

Regards
S. van Els
SAvanEls@cq-link.sr
 
hi,

pls try this code....

with query1 do
begin
close;
sql.clear;
sql.add('insert into bidata');
sql.add('values :id, :address');
params[0].asstring := id.text;
params[1].asstring := address.text;
execSql;
end;


... you can also use parameter by name instead of params just try to read about its parameters ok.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top