A: 

Read the question that I posted here.

http://stackoverflow.com/questions/2299450/more-efficient-way-of-adding-parameters-to-a-sqlcommand-net

Regardless of how you do it, it will still create a SqlParameter object. It's all about personal preference. The question i posted has a few different ways of doing it.

Aaron
That's not my question, I just want to remove new SqlParameter() from my code since I already implement new SqlParameter() in overload method. I have lots of palce need to replace.
CodeYun
If you have another method that you create the SQLParameter in wouldn't you just replace the call to new SQLParamater with a call to your overloaded method and pass in the same parameters you pass the the SQLParameter constructor? It might also help if you posted your overloaded method and how you want to use it.
cptScarlet
+4  A: 

If you are looking for a simple search/replace, then try

  1. Ctrl+Shift+H (Replace in files)
  2. Select 'Use regular expressions'
  3. Enter this regex in the 'Find what' field: new SqlParameter({.*})
  4. Enter this in the 'Replace with' field: \1
  5. Hit 'Replace All'
Eric Eijkelenboom
Hi Eric, it partially works. it replaced new SqlParameter("@Description", SqlDbType.NChar, 1500) to ("@Description", SqlDbType.NChar, 1500)but i want to remove () as well, can you help?
CodeYun
Sorry, made a typo there! Use: new SqlParameter\({.*}\)
Eric Eijkelenboom
Cool! It works. Thanks a lot
CodeYun
One more problem here it doesn't work in the following secnario: objCommand.Parameters.Add(new SqlParameter("@strXML", SqlDbType.NText, strXML.Length)).Value = strXML.ToString();has been replaced as :objCommand.Parameters.Add("@strXML", SqlDbType.NText, strXML.Length)).Value = strXML.ToString(;
CodeYun
I tried new SqlParameter\({[^)]*}\) it works for about case
CodeYun
A: 

Do a replace all on new SqlParameter( with blank.
Then, do a replace all on ) with blank.

shahkalpesh
Removing all close-brackets in his code is probably *not* the desired outcome!
Dan Puzey
@Dan: Ofcourse, user will have to be responsible to see that there isn't any other thing (other than statements with new SQLParameter...).
shahkalpesh
+1  A: 

You can write a script that use regular expression to handle the parsing and replacing.

David