“不允许从数据类型money到varchar的隐性转换,请使用convert函数来运行此查询。”(这是程序返回的错误。
我的源代码是这样的:
var
str:string;
begin
with ADOConnection1 do
begin
try
begintrans; //启动Transcation
With ADOStoredProc1 do
begin
ADOStoredProc1.Connection:=ADOConnection1;
ADOStoredProc1.ProcedureName:='P_BaseInfo_insert_1;1'; Parameters.ParamValues['@Gtin_2']:='06901234567892';
Parameters.ParamValues['@Gln_3']:='1234567890123';
Parameters.ParamValues['@Cn_Name_5']:='maleihaoyun';
Parameters.ParamValues['@En_Name_6']:='hello what are you ';
Parameters.ParamValues['@Brand_cn_7']:='dfdfdf';
Parameters.ParamValues['@brand_en_8']:='2';
Parameters.ParamValues['@Short_dscrpt_cn_9']:='2';
Parameters.ParamValues['@Short_dscrpt_en_10']:='2';
Parameters.ParamValues['@keyWord_cn_11']:='2';
Parameters.ParamValues['@keyWord_en_12']:='2';
Parameters.ParamValues['@Origin_13']:='1';
Parameters.ParamValues['@Specification_14']:='2';
Parameters.ParamValues['@Tgt_mkt_code_15']:='2';
Parameters.ParamValues['@et_date_16']:=FormatDatetime('YYYY-MM-DD HH:MM:SS',2000-03-23);
Parameters.ParamValues['@Valid_date_17']:=strtoint('2');
Parameters.ParamValues['@Pkg_code_18']:='UVQ';
Parameters.ParamValues['@Pkg_length_19']:=strtofloat('2');
Parameters.ParamValues['@Pkg_Depth_21']:=strtofloat('2');
Parameters.ParamValues['@pkg_width_20']:=strtofloat('2');
Parameters.ParamValues['@pkg_Unit_22']:='MGM';
Prepared; adostoredproc1.ExecProc;
Str:=Inttostr(ADOStoredProc1.Parameters.ParamValues['@Info_id_1']);
end;
// Raise Exception.Create('提交数据成功,请查实!');
showmessage('ok');
committrans;
Except
begin
rollbacktrans;
Raise Exception.Create('提交数据失败,请查实!');
end;
end;
end;
end;
请大家多多帮忙,谢谢!
我的源代码是这样的:
var
str:string;
begin
with ADOConnection1 do
begin
try
begintrans; //启动Transcation
With ADOStoredProc1 do
begin
ADOStoredProc1.Connection:=ADOConnection1;
ADOStoredProc1.ProcedureName:='P_BaseInfo_insert_1;1'; Parameters.ParamValues['@Gtin_2']:='06901234567892';
Parameters.ParamValues['@Gln_3']:='1234567890123';
Parameters.ParamValues['@Cn_Name_5']:='maleihaoyun';
Parameters.ParamValues['@En_Name_6']:='hello what are you ';
Parameters.ParamValues['@Brand_cn_7']:='dfdfdf';
Parameters.ParamValues['@brand_en_8']:='2';
Parameters.ParamValues['@Short_dscrpt_cn_9']:='2';
Parameters.ParamValues['@Short_dscrpt_en_10']:='2';
Parameters.ParamValues['@keyWord_cn_11']:='2';
Parameters.ParamValues['@keyWord_en_12']:='2';
Parameters.ParamValues['@Origin_13']:='1';
Parameters.ParamValues['@Specification_14']:='2';
Parameters.ParamValues['@Tgt_mkt_code_15']:='2';
Parameters.ParamValues['@et_date_16']:=FormatDatetime('YYYY-MM-DD HH:MM:SS',2000-03-23);
Parameters.ParamValues['@Valid_date_17']:=strtoint('2');
Parameters.ParamValues['@Pkg_code_18']:='UVQ';
Parameters.ParamValues['@Pkg_length_19']:=strtofloat('2');
Parameters.ParamValues['@Pkg_Depth_21']:=strtofloat('2');
Parameters.ParamValues['@pkg_width_20']:=strtofloat('2');
Parameters.ParamValues['@pkg_Unit_22']:='MGM';
Prepared; adostoredproc1.ExecProc;
Str:=Inttostr(ADOStoredProc1.Parameters.ParamValues['@Info_id_1']);
end;
// Raise Exception.Create('提交数据成功,请查实!');
showmessage('ok');
committrans;
Except
begin
rollbacktrans;
Raise Exception.Create('提交数据失败,请查实!');
end;
end;
end;
end;
请大家多多帮忙,谢谢!
谢谢
FormatDatetime('YYYY-MM-DD HH:MM:SS',StrToDate('2000-03-23'));其他的错误我也认为是在存储过程里,和delphi代码无关
(@info_id_1 [info_id] OUTPUT,
@gtin_2 [gtin],
@gln_3 [gln],
@firm_id_4 [varchar](10),
@cn_name_5 [varchar](80),
@en_name_6 [varchar](80),
@brand_cn_7 [varchar](20),
@brand_en_8 [varchar](20),
@short_dscrpt_cn_9 [varchar](30),
@short_dscrpt_en_10 [varchar](30),
@keyword_cn_11 [varchar](12),
@keyword_en_12 [varchar](12),
@origin_13 [varchar](3),
@specification_14 [varchar](30),
@tgt_mkt_code_15 [varchar](3),
@et_date_16 [datetime],
@valid_date_17 [numeric],
@pkg_code_18 [varchar](3),
@pkg_length_19 [measurement],
@pkg_width_20 [measurement],
@pkg_depth_21 [measurement],
@pkg_unit_22 [varchar](3),
@status_23 [numeric],
@inf_level_24 [numeric],
@last_change_25 [datetime],
@oper_acct_26 [varchar](20),
@pub_date_27 [datetime],
@chk_acct_28 [varchar](20),
@chk_date_29 [datetime],
@card_30 [varchar](50))AS INSERT INTO [prd].[chp].[BaseInfo]
([gtin],
[gln],
[firm_id],
[cn_name],
[en_name],
[brand_cn],
[brand_en],
[short_dscrpt_cn],
[short_dscrpt_en],
[keyword_cn],
[keyword_en],
[origin],
[specification],
[tgt_mkt_code],
[et_date],
[valid_date],
[pkg_code],
[pkg_length],
[pkg_width],
[pkg_depth],
[pkg_unit],
[status],
[inf_level],
[last_change],
[oper_acct],
[pub_date],
[chk_acct],
[chk_date],
[card])
VALUES
(@gtin_2,
@gln_3,
@firm_id_4,
@cn_name_5,
@en_name_6,
@brand_cn_7,
@brand_en_8,
@short_dscrpt_cn_9,
@short_dscrpt_en_10,
@keyword_cn_11,
@keyword_en_12,
@origin_13,
@specification_14,
@tgt_mkt_code_15,
@et_date_16,
@valid_date_17,
@pkg_code_18,
@pkg_length_19,
@pkg_width_20,
@pkg_depth_21,
@pkg_unit_22,
@status_23,
@inf_level_24,
@last_change_25,
@oper_acct_26,
@pub_date_27,
@chk_acct_28,
@chk_date_29,
@card_30)SET @info_id_1 = @@IDENTITY GO
存储过程是这样的,请帮我看看,好吗?
可能[prd].[chp].[BaseInfo] 表和傳進來的參數類型不符.我想是儲存過程問題