Tech News

Store Procedure?


Example:
CREATE PROCEDURE dbo.QSPStudent
(
@option int,
@id int,
@name varchar(50)=null,
@mobile bigint=null,
@email varchar(50)=null,
@password varchar(50)=null,
@confirm_password varchar(50)=null
)
AS
BEGIN

begin
if @option =1
select name, mobile from student
end

begin
if @option = 2
insert into student(id,name,mobile,email,password,confirm_password)values(@id,@name,@mobile,@email,@password,@confirm_password)
end

begin
if @option=3
update student set name=@name,mobile=@mobile,email=@email,password=@password,confirm_password=@confirm_password where id=@id
end

begin
if @option = 4
delete from student where id=@id
end
END
———————————————————————————————————
  protected void cmdInsert_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                // GetStudentId();
                string str = “Exec QSPStudent 2,” + TextBox6.Text + “, ‘” + TextBox1.Text + “‘, ” + TextBox2.Text + “, ‘” + TextBox3.Text + “‘, ‘” + TextBox4.Text + “‘, ‘” + TextBox5.Text + “‘”;
                dm.SqlExecuteQuery(str, 100);
                fillGrid();
            }
            else
            {

            }
        }

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x