Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 pass paramter to sql sp

Author  Topic 

CrazyT
Yak Posting Veteran

73 Posts

Posted - 2010-06-22 : 14:04:55
kind of a .net/sql question

converting some old code from 1.1 to 3.5

i noticed that they are sending all the sql statement like the following

sp_name 'value1', 'value2', 'value3'

it works but i have never seen it like this. ive always done sql parameters

any issues with the above method



Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-06-23 : 02:12:37
We'd need some more info to give a 100% accurate answer but passing parameters using .Add(... is ALWAYS the best. If the procedure call is formatted like a regular inline sql query (string myQuery = @"Select * from table") or a strigbuilder or something you'll be vulnerable to sql injection and also might be a victim of inefficient code (recompiles).

If it's not too much of a hassle you should change them all to sql parameters.

- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com
Go to Top of Page

CrazyT
Yak Posting Veteran

73 Posts

Posted - 2010-06-24 : 14:05:06
Im going to switch it to sql parameters. thanks
Go to Top of Page
   

- Advertisement -