Home > Back-end >  The client to the server to insert a record error, parameter XXX no default value, please help me to
The client to the server to insert a record error, parameter XXX no default value, please help me to

Time:05-22

First of all, I am a novice, the multi-layer data structure development is not clear, it USES the access database as a Shared, the client through the IP access, data module collocation is Tadoconnection Tadoquery - TDataSetProvider - the TClientDataSet - Tdatasource, also do not need to register, etc, in the connection and read data is no problem, save and then exit the program, for simple direct use of Tadoquery insert a record, in the debugging errors: parameter kshibh no default value, for some reason

With dm1. Qry_cj do
The begin
Dm1. Qry_cj. Close;
Dm1. Qry_cj. SQL. The Clear;
Dm1. Qry_cj. SQL. The Add (' insert into chengji ([kshibianhao], [kshbianhao]) values (kshibh KSHBH) ');
Dm1. Qry_cj. ExecSQL;
end;

CodePudding user response:


 
Var
Param: TParameter;
.
SQL. The Clear;
SQL. Text:="INSERT INTO ChengJi ([kShiBianHao], [kShBianHao]) VALUES (kshibh, : KSHBH) ';
Param:=the Parameters ParamByName (' kshibh ');
Param. DataType:=ftInteger;//assumptions are integers;
Param. Value:=10010;//set the field value here,
.

//can (just flawed) as follows:
SQL. The Clear;
SQL. Text:=Format (' INSERT INTO ChengJi ([kShiBianHao], [kShBianHao]) VALUES (% d, % d) ', [kshibh KSHBH]));
ExecSQL;

CodePudding user response:

Upstairs right, can also be debugged in the SQL statement, into the statement
Have quote field is plus

CodePudding user response:

Obvious grammatical errors

With dm1. Qry_cj do
The begin
Dm1. Qry_cj. Close;
Dm1. Qry_cj. SQL. The Clear;
Dm1. Qry_cj. SQL. The Add (' insert into chengji ([' + kshibianhao +], [' + kshbianhao + ']) values (kshibh KSHBH) ');
Dm1. Qry_cj. ExecSQL;
end;

Kshibianhao is integer series, plus IntToStr (kshibianhao)
Dm1. Qry_cj. SQL. The Add (' insert into chengji ([' + IntToStr (kshibianhao) + '], [' + IntToStr (kshbianhao) + ']) values (kshibh KSHBH) ');
  • Related