SqlConnection cn = null;
SqlCommand cmd = null;
SqlDataAdapter da = null;
//string
cs = @"Data
Source=(LocalDB)\v11.0;AttachDbFilename='|DataDirectory|ExperimentData.mdf';Integrated
Security=True";
string cs = @"Data
Source=PC-154\SQLEXPRESS;Initial Catalog=AdminPanel;Integrated
Security=True";
protected void Page_Load(object sender, EventArgs e)
{
Connection();
Insert();
GetAllUsers();
}
private void Connection()
{
try
{
cn
= new SqlConnection(cs);
cn.Open();
}
catch (Exception ex)
{
throw ex;
}
}
private void Insert()
{
Connection();
cmd
= new SqlCommand();
cmd.Connection
= cn;
cmd.CommandType
= CommandType.StoredProcedure;
cmd.CommandText
= "PI_Users";
cmd.Parameters.AddWithValue("Name", "Brijesh");
cmd.ExecuteNonQuery();
}
private void GetAllUsers()
{
Connection();
cmd
= new SqlCommand();
cmd.Connection
= cn;
cmd.CommandType
= CommandType.StoredProcedure;
cmd.CommandText
= "PS_Users";
da
= new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
}
Comments
Post a Comment