first I want to emphasize that this code is working in 99% of the times, but every once in a while clients complain for receiving this error. I have the bellow code for passing 2 parameters to a stored procedure. frmSetLoggerTime is a form with a datetimepicker (dtpToDate). Did anyone came across this issue? I'm using Borland Delphi 7 with SQL Server 2008.
首先我要强调的是,这段代码在99%的时间里都有效,但每隔一段时间客户就会抱怨收到这个错误。我有用于将2个参数传递给存储过程的波纹管代码。 frmSetLoggerTime是一个带有datetimepicker(dtpToDate)的表单。有没有人遇到过这个问题?我正在使用Borland Delphi 7和SQL Server 2008。
procedure TFormDBManager.ActionSetLoggerTimeExecute(Sender: TObject);
var
frmSetLoggerTime: TfrmSetLoggerTime;
var
RecAffected, tmpOleVar:OleVariant;
cmdObj: _Command;
ParDataLoggerID, ParUdapteTime :_Parameter;
begin
tmpOleVar:=OleCtrls.EmptyParam;
frmSetLoggerTime := TfrmSetLoggerTime.Create(self);
try
frmSetLoggerTime.dtpToDate.DateTime := now;
if frmSetLoggerTime.ShowModal = mrOK then
begin
cmdObj := CoCommand.Create;
cmdObj.Set_ActiveConnection(DBRemoteModule.SLogConnection.ConnectionObject);
cmdObj.CommandType := adCmdStoredProc;
cmdObj.CommandText := 'UpdateRebelDateTime';
ParUdapteTime := cmdObj.CreateParameter('@UdapteTime', adDate, adParamInput, 3, frmSetLoggerTime.dtpToDate.DateTime);
cmdObj.Parameters.Append(ParUdapteTime);
ParDataLoggerID := cmdObj.CreateParameter('@DataLoggerID', adInteger, adParamInput, 4, QueryLogger.FieldByName('DataLoggerID').AsInteger);
cmdObj.Parameters.Append(ParDataLoggerID);
cmdObj.Execute(RecAffected, tmpOleVar, 0);
end;
finally
frmSetLoggerTime.free;
end;
end;
Here is the stored procedure:
这是存储过程:
ALTER PROCEDURE [dbo].[UpdateRebelDateTime] @UpdateDateTime datetime, @DataLoggerID int
AS
SET NOCOUNT ON
UPDATE tblDataLoggers SET UpdateDateTime = @UpdateDateTime, UpdateDateTimeDelay = GETUTCDATE()
WHERE DataLoggerID = @DataLoggerID
1 个解决方案
#1
0
You are using another parameter name: @UdapteTime
您正在使用另一个参数名称:@UdapteTime
Your code:
你的代码:
ParUdapteTime := cmdObj.CreateParameter('@UdapteTime', adDate, adParamInput, 3, frmSetLoggerTime.dtpToDate.DateTime);
And it expects:
它预计:
@UpdateDateTime
#1
0
You are using another parameter name: @UdapteTime
您正在使用另一个参数名称:@UdapteTime
Your code:
你的代码:
ParUdapteTime := cmdObj.CreateParameter('@UdapteTime', adDate, adParamInput, 3, frmSetLoggerTime.dtpToDate.DateTime);
And it expects:
它预计:
@UpdateDateTime