473,402 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Dealing to a SQL SP with lots of params

Hi,

I have about 30 sql SP with around 50 paramaters each.

Currently in each SP, each param has its own name (prmC, prmD etc). Just
out of being a bit lazy, is there away that each param can have the same
name.. just savings me from having to rename each param as I go (i am cut
and past a single block over and over as many times as needed for each SP)

Thanks

Dim prmC = New SqlParameter("@City ", Data.SqlDbType.NVarChar,
50)
prmC.Value = strRole
SqlCommand.Parameters.Add(prmC)

Dim prmD = New SqlParameter("@State ", Data.SqlDbType.NVarChar,
50)
prmD.Value = strCountry
SqlCommand.Parameters.Add(prmD)

Dim prmE = New SqlParameter("@country", Data.SqlDbType.NVarChar,
50)
prmE.Value = strCountry
SqlCommand.Parameters.Add(prmE)

Aug 11 '07 #1
5 1190
On Sat, 11 Aug 2007 21:58:09 +0100, "Aussie Rules"
<Au*********@nospam.nospamwrote:
>Hi,

I have about 30 sql SP with around 50 paramaters each.

Currently in each SP, each param has its own name (prmC, prmD etc). Just
out of being a bit lazy, is there away that each param can have the same
name.. just savings me from having to rename each param as I go (i am cut
and past a single block over and over as many times as needed for each SP)

Thanks

Dim prmC = New SqlParameter("@City ", Data.SqlDbType.NVarChar,
50)
prmC.Value = strRole
SqlCommand.Parameters.Add(prmC)

Dim prmD = New SqlParameter("@State ", Data.SqlDbType.NVarChar,
50)
prmD.Value = strCountry
SqlCommand.Parameters.Add(prmD)

Dim prmE = New SqlParameter("@country", Data.SqlDbType.NVarChar,
50)
prmE.Value = strCountry
SqlCommand.Parameters.Add(prmE)
There is no need to keep references to all of the parameters.

Dim prm as SqlParameter

prm = New SqlParameter(...)
prm.Value = ...
SqlCommand.Parameters.Add(prm)

prm = New SqlParameter(...)
prm.Value = ...
SqlCommand.Parameters.Add(prm)
....
Aug 12 '07 #2
"Aussie Rules" <Au*********@nospam.nospamwrote in
news:eE**************@TK2MSFTNGP02.phx.gbl:
I have about 30 sql SP with around 50 paramaters each.

Currently in each SP, each param has its own name (prmC, prmD etc).
Just out of being a bit lazy, is there away that each param can have
the same name.. just savings me from having to rename each param as I
go (i am cut and past a single block over and over as many times as
needed for each SP)
Have you looked into a DAL framework like LLBLGen Pro or similar? These
applications hide the need to write low level SQL code yet still provides
you with very powerful features.

Microsoft has their own framework coming out (Linq/Dlinq) but it won't be
available till next year.
Aug 12 '07 #3
Hi Aussie,

As for the following request you mentioned::
>>>>>>
is there away that each param can have the same name..
<<<<<<<<

do you mean you want to make all those SqlParameter for the store procedure
share the same variable name? If so, I think the means Jack mentioned is
t he reasonable approach, you can only define a single SqlParameter
variable reference and reuse it for all the parameters in your store
procedure(or sql statement). However, you still need to create
instance(with the proper parameters in construtor) since each parameter
have different name and type in your database defined store procedure.
Does this help you?

If you have any more specific question or anything we missed, please feel
free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 13 '07 #4
If Aussie,

Does the suggetion about reuse a single SqlParameter object helps you here?
If there is any further questions on this, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 15 '07 #5
Hi,

Another thanks for helping me solve this.

THanks
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:Bx**************@TK2MSFTNGHUB02.phx.gbl...
If Aussie,

Does the suggetion about reuse a single SqlParameter object helps you
here?
If there is any further questions on this, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.
Aug 15 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tom Willis | last post by:
How are the expert pythoneers dealing with config files? Is there anything similair to .net's config files or java's .properties? A quick search on google didn't return anything that looked...
44
by: flyingfred0 | last post by:
A small software team (developers, leads and even the manager when he's had time) has been using (wx)Python/PostgreSQL for over 2 years and developed a successful 1.0 release of a client/server...
0
by: Mihaly | last post by:
Hello, i'm using a VC++ com+ object, it's reference in vs .net, this com object have a function that have to params, the interop com object recive Object Params and the original com object say...
2
by: Tobias Olbort | last post by:
Hello, i've a outer function, which takes a params-array as a parameter. I want to pass this array to inner function with a params-array (e. g. string.format). When i've passed an integer to...
3
by: Stan Huff | last post by:
Is there any way to disable the "params" on a particular invocation so that one can pass an array containing the arguments and not have receiver get an array having you argument array stuffed into...
8
by: David Duerrenmatt | last post by:
Hi there For some reasons, I've to use Python 1.5.2 and am looking for a workaround: In newer Python versions, I can call a function this way: func = some_function func(*params) Then,...
2
by: FFMG | last post by:
Hi, I was looking at http://www.php.net/manual/en/function.call-user-func-array.php and I was wondering... Given, // -- function foo( &$params) {
16
by: pereges | last post by:
ok so i have written a program in C where I am dealing with huge data(millions and lots of iterations involved) and for some reason the screen tends to freeze and I get no output every time I...
5
by: _dee | last post by:
I'm working on a port of a legacy app originally written in C. Data was compacted into bit fields. Are there any sites or books that cover optimized handling of this type of data? I'd need to...
0
by: raylopez99 | last post by:
I ran afoul of this Compiler error CS1612 recently, when trying to modify a Point, which I had made have a property. It's pointless to do this (initially it will compile, but you'll run into...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.