You are on page 1of 2

8/11/2017 Dotnet springs: 3-Tier using Single Query(Insert,Update)

More Next Blog 82.raghu@gmail.com Dashboard Sign Out

Dotnet springs
Monday, 16 July 2012 Blog Archive
2017 (3)
3-Tier using Single Query(Insert,Update) 2016 (2)

Bal.cs: 2012 (16)


December (1)

November (1)
public class bal
{ October (3)
public int insert(string name,string place,int Id,int mode) August (2)
{
July (9)
DAL s = new DAL();
return s.insert(name, place,Id,1); News Title image an gridview display

3 tier insert,update,delete gridview using


} c#
public int update(string name, string place, int Id,int mode) UPDATE USING 3 TIER
{ ARCHITECTURE (CASCADING
DROPDO...
DAL s = new DAL();
return s.update(name, place, Id,2); PASSWORD CHECKING & CHANGE
PASSWORD
} Newsletter to single user and multiple
} users(email...
Dal.cs: 3-Tier using Single Query(Insert,Update)
public int insert(string name, string place,int Id,int mode)
Email and verification link
{
con.Open(); Jquery image crop
SqlCommand cmd = new SqlCommand("Ins_data", con);
insert and update using single query
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Name", name);
cmd.Parameters.AddWithValue("@Place", place);
cmd.Parameters.AddWithValue("@mode", mode); About Me
cmd.Parameters.AddWithValue("@Id", Id); hariharan
return cmd.ExecuteNonQuery();
View my complete profile
con.Close();

}
public int update(string name, string place, int Id,int mode)
{
con.Open();
SqlCommand cmd = new SqlCommand("Ins_data", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Name", name);
cmd.Parameters.AddWithValue("@Place", place);
cmd.Parameters.AddWithValue("@mode", mode);
cmd.Parameters.AddWithValue("@Id", Id);
return cmd.ExecuteNonQuery();
con.Close();

}
Default

bal s = new bal(); //call in public

protected void Button1_Click(object sender, EventArgs e)


{

string name = TextBox1.Text;


string place = TextBox2.Text;
int Id = 0;
s.insert(name, place,Id,1);

http://dotnetsprings.blogspot.in/2012/07/3-tier-using-single-queryinsertupdate.html 1/2
8/11/2017 Dotnet springs: 3-Tier using Single Query(Insert,Update)

}
protected void Button2_Click(object sender, EventArgs e)
{
string name = TextBox1.Text;
string place = TextBox2.Text;
int Id =Convert.ToInt16( TextBox3.Text);
s.update(name, place, Id,2);
}

stored pro:

ALTER procedure [dbo].[Ins_data](@Name varchar(50),@place varchar(50),@Id int,@mode


int)
as
begin
if(@mode=1)
begin
insert into dbo.Table_1 (Name,Place) values(@Name,@place)
end
else if (@mode=2)
begin
update dbo.Table_1 set Name=@Name,Place=@place where Id=@Id
end
end

Posted by hariharan at 05:25

No comments:

Post a Comment

Enter your comment...

Comment as: Raghu Gowda (Google) Sign out

Publish Preview Notify me

Newer Post Home Older Post

Subscribe to: Post Comments (Atom)

Watermark theme. Powered by Blogger.

http://dotnetsprings.blogspot.in/2012/07/3-tier-using-single-queryinsertupdate.html 2/2

You might also like