Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SqlHelper, SqlParameter and Orders

Status
Not open for further replies.

Akusei

Programmer
Jul 15, 2003
90
US
Are the following two blocks of psuedo-code the same, or will one pass information to the sproc differently.

Case 1
Define Sql Parameter 1 in array as @Param1
Define Sql Parameter 2 in array as @Param2
Define Sql Parameter 3 in array as @Param3

SqlHelper(con, "sproc", ParameterArray)

And

Case 2
Define Sql Parameter 1 in array as @Param2
Define Sql Parameter 2 in array as @Param1
Define Sql Parameter 3 in array as @Param3

SqlHelper(con, "sproc", ParameterArray)


The sproc is like this
CREATE Procedure dbo.sproc
(
@Param1 int,
@Param2 int,
@Param3 int
)

Logic would dictate that Parameter 1 in case 1 would map to @Param1 because it is named such, and Parameter 2 in case 2 would map to @Param1 because it is named so... However, when I pass the values in, in both these cases the order that the parameter is defined MUST match the order of the parameters in the sproc definition! Is this the case or am I doing something wrong?

Best Regards,
Akusei
 
You'll want to define your parameters in the same order in which they're defined. You would think that it would match it up for you, but it doesn't really.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
That is really inconvenient... thanks.
 
I did some more digging and found this article

It states the following:
In each of the samples in this article, the parameters are added to the Parameters collection of the Command object. The SQL Server .NET data provider (SqlClient) supports named parameters. Therefore, when you use the SqlCommand object, you do not have add the parameters in any particular order, but the parameters must have the correct name. In this case, you must add the at sign (@) prefix to the parameter names.

My code uses named parameters and still requires it to be in a specific order, and yes, I am using ADO.NET, not OLE DB.NET. Any ideas?

P.S. I am using MDAAB (Microsoft Data Access Application Block)... it is a wrapper around ADO.NET.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top