If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Passing SQL Server stored procedure parameter names via Delphi

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-25-11, 15:34
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
Passing SQL Server stored procedure parameter names via Delphi

I'm new to Delphi and trying to find my way around calling some stored procedures in SQL Server.

This is the code I have been working with at the moment and it works....
Code:
FConnection := TADOConnection.Create(nil);
FMetaDataSP := TADOStoredProc.Create(nil);
LoadDBSettings;

FMetaDataSP.Connection := FConnection;
FMetaDataSP.ProcedureName := 'Messaging.ListMessageSections';
FMetaDataSP.Parameters.CreateParameter('@ReferralID', ftInteger, pdInput, 4, null);
FMetaDataSP.Parameters.CreateParameter('@ConsumerID', ftInteger, pdInput, 4, null);

Dataset := FMetaDataSP;
FMetaDataSP.Parameters.ParamByName('@ReferralID').Value := ReferralID;
FMetaDataSP.Parameters.ParamByName('@ConsumerID').Value := ConsumerID;
.... but when I do a profile in SQL Server I see this is the SQL that is executed.
Code:
exec Messaging.ListMessageSections 1,1
What I want is this instead...
Code:
exec Messaging.ListMessageSections @ReferralID=1, @ConsumerID=1
so that the ordering of the parameters in the code base are not important.

Is this possible?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On