Stored procedure for
insert:
create procedure sample_ins(@empid int,@empname varchar(50),@empmobileno decimal(18,0),@empaddress varchar(max)) as begin insert into sample (empid,empname,empmobileno,empaddress)values(@empid,@empname, @empmobileno,@empaddress) end
Coding for insert button:
try { SqlCommand cmd=new SqlCommand ("sample_ins",con); [Link]=[Link]; [Link](); [Link]("empid",[Link]).Value=[Link]; [Link]("empname",[Link]).Value=TextBox2. Text; [Link]("empmobileno",[Link]). Value=[Link]; [Link]("empaddress",[Link]).Value=TextBo [Link]; [Link]("password", [Link]).Value = [Link]; [Link](); [Link](); //For clearing all the fields [Link] = ""; [Link] = ""; [Link] = ""; [Link] = ""; [Link] = ""; [Link]("Inserted Successfully...!"); } catch(Exception ex) { [Link]([Link]); } finally { [Link](); }
Stored procedure for Update:
create procedure sample_up(@empid int,@empmobileno decimal(18,0),@empaddress varchar(max),@password varchar(50)) as begin update sample set empmobileno=@empmobileno,empaddress=@empaddress,password= @password where empid=@empid end
Coding for Update button:
try { [Link](); SqlCommand Cmd = new SqlCommand("sample_up", con); [Link] = [Link]; [Link]("@empid", [Link]).Value = [Link]; [Link]("@empmobileno", [Link]).Value = [Link]; [Link]("@empaddress", [Link]).Value = [Link]; [Link]("@password", [Link]).Value = [Link]; [Link](); //For clearing all the fields [Link] [Link] [Link] [Link] [Link] = = = = = ""; ""; ""; ""; "";
[Link]("Updated Successfully...!"); } catch (Exception ex) { [Link]("[Link]"); } finally { [Link](); }
Stored procedure for Delete:
create procedure sample_del1 (@empid int) as begin delete from sample where empid=@empid end
Coding for Delete button:
[Link](); SqlCommand Cmd = new SqlCommand("sample_del1", con); [Link] = [Link]; [Link]("@empid",[Link]); [Link](); [Link](); //For clearing all the fields [Link] [Link] [Link] [Link] [Link] = = = = = ""; ""; ""; ""; "";
[Link]("Deleted Successfully...!");
Stored procedure for
Retrieving Data:
create procedure login1(@empid int),@password varchar(20) as begin select * from sample where empid =@empid end
For Retrieving Data:
try { [Link](); SqlCommand cmd = new SqlCommand("login1", con); [Link] = [Link]; [Link]("@empid", [Link]).Value = [Link]; [Link]("@password", [Link]).Value = [Link]; SqlDataReader rdr = [Link](); if ([Link]()) { [Link]("[Link]"); } else { [Link]("Employee id was incorrect"); } } catch (Exception ex) { [Link]([Link]); }
For Connection String:
SqlConnection con=new SqlConnection("Server=SYS18;Initial Catalog=NorthWind;Integrated Security=true;Database='suneel'");
Declare the connection string in the global of the class Then we need not to declare for all the operations NOTE: In the name space import the below string
using [Link];