|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Is it possibly to specify store procedure parameters by position instead by name?I'm developing a new .NET application but using the same stored procedures (Sql Server 2000) that are in use by an old client server application. The problem is that it is common when refactoring stored procedures, to change the name of the parameters. It was not a problem since the old application uses ODBC and the parameters are called by position, not by name. But ADO.NET requires to me to specify parameters by name parm = cmd.Parameters.Add("@ParamName", SqlDbType.Int); Then when the sp get revised and updated to our new coding standard (@ParamName will be renamed to @nParamName) it will break my code. Is it any way I can specify the parameters by position, something like: parm = cmd.Parameters.Add(0, SqlDbType.Int); Any hint is welcomed. Thanks in advance Sammy Not really unless you roll the EXEC mySP parm,parm2 line yourself.
-- Show quote____________________________________ William (Bill) Vaughn Author, Mentor, Consultant Microsoft MVP INETA Speaker www.betav.com/blog/billva www.betav.com Please reply only to the newsgroup so that others can benefit. This posting is provided "AS IS" with no warranties, and confers no rights. __________________________________ "SammyBar" <sammy***@gmail.com> wrote in message news:eXpm1zsGGHA.1032@TK2MSFTNGP12.phx.gbl... > Hi, > > I'm developing a new .NET application but using the same stored procedures > (Sql Server 2000) that are in use by an old client server application. The > problem is that it is common when refactoring stored procedures, to change > the name of the parameters. It was not a problem since the old application > uses ODBC and the parameters are called by position, not by name. But > ADO.NET requires to me to specify parameters by name > parm = cmd.Parameters.Add("@ParamName", SqlDbType.Int); > > Then when the sp get revised and updated to our new coding standard > (@ParamName will be renamed to @nParamName) it will break my code. > > Is it any way I can specify the parameters by position, something like: > > parm = cmd.Parameters.Add(0, SqlDbType.Int); > > Any hint is welcomed. > > Thanks in advance > > Sammy > > This is one reason I use my code generator.
http://www.eggheadcafe.com/articles/adonet_source_code_generator.asp Show quote "SammyBar" <sammy***@gmail.com> wrote in message news:eXpm1zsGGHA.1032@TK2MSFTNGP12.phx.gbl... > Hi, > > I'm developing a new .NET application but using the same stored procedures > (Sql Server 2000) that are in use by an old client server application. The > problem is that it is common when refactoring stored procedures, to change > the name of the parameters. It was not a problem since the old application > uses ODBC and the parameters are called by position, not by name. But > ADO.NET requires to me to specify parameters by name > parm = cmd.Parameters.Add("@ParamName", SqlDbType.Int); > > Then when the sp get revised and updated to our new coding standard > (@ParamName will be renamed to @nParamName) it will break my code. > > Is it any way I can specify the parameters by position, something like: > > parm = cmd.Parameters.Add(0, SqlDbType.Int); > > Any hint is welcomed. > > Thanks in advance > > Sammy > > |
|||||||||||||||||||||||