execute stored procedure with parameters
Published: 14. December 2008 | Updated: 14. December 2008License: Microsoft Public License (MS-PL)
Categories: Databases
Tags: C# SQL
Import namespace
using System.Data.SqlClient;
Code
// create connection SqlConnection sqlConnection = new SqlConnection("..."); sqlConnection.Open(); // create command SqlCommand command = new SqlCommand("stored_procedure_name", connection); command.CommandType = CommandType.StoredProcedure; // add parameter command.Parameters.AddWithValue("@id", id); // execute int affectedRows = command.ExecuteNonQuery();
| Send us feedback about this snippet » |





