Welcome to RP's venture...Here you can find some of the relative topics like ASP.Net, C#.Net,VB.Net, SQL Server, AJAX, Javascripts, Sharepoint, WPF, WCF, Silverlight, MVC, General knowledge, Jokes, Fun, Technical, Non-Technical etc.
0

Query excecution Using Stored Procedure

Posted by Rajendra Prasad Panchati on Monday, February 15, 2010 in
Here i'm using SQL Server as my database. So i needed 1)using System.Data; 2)using System.Data.SqlClient; namespaces.

try
{
String objConnectionString= ConfigurationSettings.AppSettings["ConnectionString"];
SqlConnection objSQLConnection = new SqlConnection(objConnectionString);
SqlCommand objSQLCommand = new SqlCommand();
objSQLCommand .Connection = objSQLConnection ;
objSQLCommand .CommandType = CommandType.StoredProcedure;
objSQLCommand .CommandText = "Your Stored Procedure name";
if(objSQLConnection .State==ConnectionState.Closed)
objSQLConnection .Open()
objSQLCommand .ExecuteNonQuery();
}
catch(Exception ex)
{
Throw ex;
}
finally
{
if(objSQLConnection .State==ConnectionState.Open)
objSQLConnection .Close()
}

|

0 Comments

About Me