Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello,
i want to call stored procedure function .cs to asp.net to update records
can u guide or any snippets
Posted
Updated 1-Mar-12 17:32pm
v2
Comments
joe_j 13-Feb-13 4:17am    
Do you already have a stored proc in place?

using(SqlConnection conn = new SqlConnection("Data 
Source=localhost;Database=Northwind;Integrated Security=SSPI"))
{
SqlCommand command = new SqlCommand("spName", conn);
command.CommandType = CommandType.StoredProcedure;
conn.Open();
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
    Console.WriteLine(reader["ProductName"]);
}
}


If you want to pass input parameters you can pass

C#
command.Parameters.Add("@inputPar", SqlDbType.Int).Value = 1;


SqlDbType is enum you can choose desirable data type to pass as input parameter and its value.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900