SqlDataSource UpdateParemeters

C

cognizance42

Hey gang,

I'm in the process of fixing an application a former programmer slap
together. We found the database design went against company standards,
so our DBA went through to fix her up. Now I'm working on the task of
fixing the UI code to interact properly with the new changes.

However, I've ran in to a strange behavior with UpdateParameters within
my SqlDataSource.

Originally, the Stored Proc calls for the following parameters:

@id int = 0,
@original_id int = 0,
@original_division_id int = 0,
@division int = 0,
@division_id int = 0,
@revenue_type varchar(100) = '',
@revenue_num int = 0

Our DBA changed to:

@original_id int = 0,
@original_division_id int = 0,
@division int = 0,
@division_id int = 0,
@revenue_type varchar(100) = '',
@revenue_num int = 0

The difference? @id has been removed. (Original programmer wasn't even
friggin using it!)

Now I've updated my SqlDataSource UpdateParameters to reflect changes,
only to find when running SQL Profiler that my stored proc is being
executed with 1 added parameter... <b>@id</b>!!

exec updRevenueType @original_id = 15, @original_division_id = 2,
@division = 2, @division_id = 2, @revenue_type = N'Broadcast
Designeeee', @revenue_num = 4020, @id = 15

Does SqlDataSource do some weirdness on the background I'm unaware of
that looks at the database scheme or something and add it's own
parameters? This is rather frustrating trying to find out where this
stray parameter is coming from! Anyone else run in to similar behavior?

More info: I'm using C# on .NET 2.0
 
N

neilphan

Did you check to see in your UI Code that you are passing in all the
RIGHT Parameters and its correct values?

My guess is that
1) Your code is not passing in all the required parameters and values,
2) The STORED PROC names in the DB does not match the CREATE/ALTER
Stored Proc Syntax

My Two Cents.....let me know how it turns out.....I have never had any
problems with Stored Procs and Paramters..

Neil
 
C

cognizance42

Turns out the original programmer had over-head in his code. setting
update parameters when he didn't need to. It threw me off, without
realizing the gridview is relying on databound controls for parameters.

He was also trying to use datakeynames, but with the select proc it's
returning PK as "id" and the update is taking as "original_id".
Updating my Procs helped keep consistancy.
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top