I have created a stored procedure sp_UpdateRate
in Sql Server 2005 database and in my C# application i have a decimal array containing multiple rates. Now, i want to pass that array into my stored procedure. the length of array is not static. How do i do this. Is there any array type in sql parameters?
Here is my code:
decimal[] rates = new decimal[lst.Items.Count]; //lst is the ListBox control that containing list of rate.
for (int i=0;i<lst.Items.Count;i++)
{
rates[i]=Convert.ToDecimal(lst.Items[i]);
}
SqlCommand cmd = Cnn.CreateCommand; //Cnn is the SqlConnection class object
cmd.CommandText = "sp_UpdateRate";
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
My stored procedure is here
Alter Procedure sp_UpdateRate(@rate decimal(9,2))
AS
BEGIN
--I want to Update my rates here.
Update tblRate SET LastUpdate=GetDate(), NewRate=(@rate * 1.658) Where rate=@rate
END