SqlConnection con=new SqlConnection("User ID=" + ConfigurationSettings.AppSettings.Get("UserName").ToString() + ";Password=" + ConfigurationSettings.AppSettings.Get("Password").ToString() + ";Initial Catalog=" + ConfigurationSettings.AppSettings.Get("DBName").ToString() + ";Data Source=" + ConfigurationSettings.AppSettings.Get("ServerName").ToString() + ";Persist Security Info= true;");
con.Open();
SqlCommand cmd=new SqlCommand("SPNAME",con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@SPPARAM", PARAM));
cmd.CommandTimeout=0;
SqlTransaction t=con.BeginTransaction();
cmd.Transaction=t;
try
{
cmd.ExecuteNonQuery();
t.Commit();
con.Close();
}
catch(Exception ex)
{
t.Rollback();
con.Close();
string s = ex.Message;
}
No comments:
Post a Comment