We actually migrate our project from Delphi 6 to Delphi 2007.
There is a problem with the TStoredProcName when accessing the params.
We use the DbExpress driver for MS SQL 5.0.3.
Here is an exemple with the MS SQL stored procedure "sp_helpsrvrolemember"
(http://msdn.microsoft.com/fr-fr/library/ms188772.aspx) :
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
begin
SQLConnection1.DriverName := 'DevartSQLServer';
SQLConnection1.LibraryName := 'dbexpsda40.dll';
SQLConnection1.VendorLib := 'sqloledb.dll';
SQLConnection1.GetDriverFunc := 'getSQLDriverSQLServer';
SQLConnection1.Params.Clear;
SQLConnection1.Params.Values[{!4}'HostName'] := 'vm-dev-sql2k5';
SQLConnection1.Params.Values[{!4}'DataBase'] := 'PLW3LHD2';
SQLConnection1.Params.Values[{!4}'User_Name'] := 'sa';
SQLConnection1.Params.Values[{!4}'Password'] := '****';
SQLConnection1.Params.Values[{!4}'CommandTimeOut'] := '0';
SQLConnection1.LoginPrompt := false;
SQLConnection1.Open;
try
SQLStoredProc1.SQLConnection := SQLConnection1;
SQLStoredProc1.StoredProcName := 'sp_helpsrvrolemember';
Label1.Caption := IntToStr(SQLStoredProc1.Params.Count);
// => 0 in D2007, 2 in D6
SQLStoredProc1.Params.ParamByName('srvrolename').AsString := {!4}'sysadmin';
// => Exception in D2007
finally
SQLConnection1.Close;
end;
end;
With Delphi 2007 we get a EDatabaseError with message 'SQLStoredProc1: Parameter 'srvrolename' not found'.
It seems that the problem only appears for built-in MS SQL stored proc.
We don't have this problem with our own stored proc.
What's wrong ?
Jerome DUVAL
Holy-Dis