you can add a class and make method like
public class Db
{
public Db()
{
}
public static SqlConnection GetConnection()
{
SqlConnection cn = new SqlConnection();
cn.ConnectionString=@"DataSource=.\SQLEXPRESS;AttachDbFilename=E:\prashantcs\crm111\CRM111.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
cn.Open();
return cn;
}
}
use this method as
SqlCommand cmd12111 = new SqlCommand();
cmd12111.CommandText = "insert_File_Request1";
cmd12111.CommandType = CommandType.StoredProcedure;
cmd12111.Connection = Db.GetConnection();
cmd12111.Parameters.AddWithValue("ReqControlNo", ReqControlNo);
cmd12111.Parameters.AddWithValue("ReqDate", ReqDate);
cmd12111.Parameters.AddWithValue("ReqTime", ReqTime);
cmd12111.ExecuteNonQuery();
cmd12111.Connection.Close();
hope it will helps you.