What is the best code to call stored procedure with many parameters?

Another way to do this is to make the SqlCommand a member field of the class, and have a member method to initialize it This is similar to the code that Visual Studio generates when you create a Component, then drag a SqlCommand onto the design surface. If you configure the SqlCommand with a parameterized query or stored procedure with parameters, then it will generate code to create the SqlParameter objects and add them to the Parameters property To use thie SqlCommand later in your code, you would do: m_Command. Parameters"@ParamName".

Value = value.

Another way to do this is to make the SqlCommand a member field of the class, and have a member method to initialize it. This is similar to the code that Visual Studio generates when you create a Component, then drag a SqlCommand onto the design surface. If you configure the SqlCommand with a parameterized query or stored procedure with parameters, then it will generate code to create the SqlParameter objects and add them to the Parameters property.To use thie SqlCommand later in your code, you would do: m_Command.

Parameters"@ParamName". Value = value.

I think it will work for me. Thank you. – Antipod Jul 2 '09 at 7:05.

Erland Sommerkog's article Arrays and Lists in SQL Server 2005 "describes a number of different ways to do this, both good and bad. " Duplicate of: Since there is no Sqlserver array parameter, what’s the best way to proceed?

Something like this... AddSqlParam("ParamName1",SqlDbType. Int,val1,ParameterDirection. Input, command); AddSqlParam("ParamName2",SqlDbType.

String,val2,ParameterDirection. Input, command); You can further refactor this by having commonly used parameters into little helper functions. For example most databases have an ID column.

So you could have a method like AddIdParam(command); I hope I conveyed my point.

This is a little bit more condensed format you could use SqlCommand command = new SqlCommand(); command.Parameters. Add(new SqlParameter("@param1", SqlDbType. NVarChar, 255)); command.

Parameterscommand.Parameters. Count - 1. Value = "value1"; command.Parameters.

Add(new SqlParameter("@param2", SqlDbType. NVarChar, 255)); command. Parameterscommand.Parameters.

Count - 1. Value = "value2"; command.Parameters. Add(new SqlParameter("@param3", SqlDbType.

NVarChar, 255)); command. Parameterscommand.Parameters. Count - 1.

Value = "value3.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions