OleDb SqlDataSource stored procedure call parameter order mixed up ?

U

User

I am using a OleDb SqlDataSource to bind to a GridView

The SqlDataSource is defined as follows:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ProviderName="System.Data.OleDb"
...
UpdateCommand="mp_Update" UpdateCommandType = "StoredProcedure"
...

<UpdateParameters>
<asp:parameter Name="@ret_val" Type="Int32"
Direction=ReturnValue />
<asp:parameter Name="usr_id" Type="String" Size="32" />
<asp:parameter Name="usr_name" Type="String" Size="32" />
</UpdateParameters>
</asp:SqlDataSource>


The UpDateCommand uses a stored procedure with a return value and two input
parameters (ie. "usr_id" and "usr_name").
The DataKeyNames in the GridView is set to "usr_id"
When the update actually happens, somehow the SqlDataSource is mangling the
order of the parameters.
In SQL Server Profiler, I see that it issues mp_Update <usr_name>, <usr_id>
instead of mp_Update <usr_id>, <usr_name>
as I would have expected since I manually defined the UpdateParameters.

How can I fix this so that the parameter order in the call will match the
stored procedure definition ??

Note: changing the SqlDataSource provider to System.Data.SqlClient does
work.
The order is still mixed up, but the provider issues mp_Update
@user_name=<usr_name>, @usr_id=<usr_id>
and thus the mangled order does not matter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top