我有以下代码Parameters.ParamByname不接受字符串值德尔福
procedure TFrmMain.ComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
ADOQuery1.close;
ADOQuery1.sql.Text := 'INSERT INTO palletweighttemp(TickCode,SchedID,BatchNo)values';
ADOQuery1.SQL.Add(' (:field1,(select SchedID from TicketBatch where TickCode =:field1),');
ADOQuery1.SQL.Add('(select BatchNo from TicketBatch where TickCode =:field1))');
ADOQuery1.Parameters.ParamByName('field1').DataType := ftString;
ADOQuery1.Parameters.ParamByName('field1').Value := ComboBox1.Text;
ADOQuery1.ExecSQL;
PopulateDBGrid;
ComboBox1.SetFocus;
end;
end;
我填充使用
procedure TFrmMain.PopulateBoxes();
begin
ComboBox1.SetFocus;
ComboBox1.Perform(WM_SYSKEYDOWN, VK_TAB, 0);
ComboBox1.clear;
ADOQuery1.sql.add
('select * from TicketBatch where isProcesed = 0 and TickCode is not null');
ADOQuery1.open;
ComboBox1.Text := '';
while not ADOQuery1.Eof do
begin
ComboBox1.Items.add(ADOQuery1.FieldByName('TickCode').AsString);
ADOQuery1.Next;
end;
ADOQuery1.close;
end;
如果我回车来运行我的Combobox1KeyPress程序错误弹出我的组合框那
我假设这是因为它需要一个整数,目前是一个字符串 请帮助
那么'TickCode'列是一个'int'类型?如果是这样,不要为它定义一个参数作为字符串,甚至不会认为你可以在那里插入文本值“F105165”。该值意味着是十六进制数字还是要存储到该列的文本值? – Victoria
该值是一个字符串类型,需要将其存储为字符串 –
以调试器模式运行项目。它在什么方面停止提出这个错误?知道这条线将帮助你确定原因。 –