public string deletem(salaryinfo pr) { int i = 0; string msg = ""; //int id = string deletequery = string.Format("delete from employee2 where id={0}", pr.id); DataSet ds = new DataSet(); try { using (SqlConnection con = new SqlConnection(conString)) { SqlCommand cmd = new SqlCommand(deletequery, con); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds); da.Update(ds); } } catch (Exception ex) { } if (i > 0) { msg = string.Format("row Deleted"); } return(msg); }
public string updated(salaryinfo pr) { string msg = ""; int i = 0; // string updatequery = string.Format("update employee2 set name ={0},department={1},salary = {2} designation={3} where id={4}", pr.name, pr.department,pr.salary, pr.designation, pr.id); string updatequery = "update employee2 set name='" + pr.name + "' where id='" + pr.id + "'"; DataSet ds = new DataSet(); try { using (SqlConnection con = new SqlConnection(conString)) { SqlCommand cmd = new SqlCommand(updatequery, con); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds); da.Update(ds); } } catch (Exception ex) { } if (i > 0) { msg = string.Format("one row inserted"); } return(msg); }
public string insert(salaryinfo pr) { string insertquery = string.Format("insert into employee2(id,name,department,salary,designation)values({0},'{1}','{2}',{3},'{4}')", pr.id, pr.name, pr.department, pr.salary, pr.designation); DataSet ds = new DataSet(); int i = 0; string msg = ""; try { using (SqlConnection con = new SqlConnection(conString)) { SqlCommand cmd = new SqlCommand(insertquery, con); SqlDataAdapter da = new SqlDataAdapter(cmd); i = da.Fill(ds); da.Update(ds); } } catch (Exception ex) { } if (i > 0) { msg = string.Format("one row inserted"); } return(msg); }
protected void Button1_Click(object sender, EventArgs e) { int idn = Convert.ToInt32(TextBox1.Text); DataLayer2 dl = new DataLayer2(); salaryinfo dr = new salaryinfo { id = idn }; string msg = dl.deletem(dr); }
protected void Button3_Click(object sender, EventArgs e) { int idn = Convert.ToInt32(TextBox1.Text); string name = TextBox2.Text; //string department = TextBox3.Text; // int salary = Convert.ToInt32(TextBox4.Text); // string designation = TextBox5.Text; salaryinfo dr = new salaryinfo { id = idn, name = name }; DataLayer2 d1 = new DataLayer2(); string msg = d1.updated(dr); }
protected void Button1_Click(object sender, EventArgs e) { if (this.IsPostBack) { int idn = Convert.ToInt32(TextBox1.Text); string name = TextBox2.Text; string department = TextBox3.Text; int salary = Convert.ToInt32(TextBox4.Text); string designation = TextBox5.Text; salaryinfo dr = new salaryinfo { id = idn, name = name, department = department, salary = salary, designation = designation }; DataLayer2 dl = new DataLayer2(); string msg = dl.insert(dr); Response.Write("<script>alert('data inserted')</script>"); } }