Wednesday, 3 December 2014

Data Table manipulation techniques 1

Data Table manipulation techniques :

Hai friend today I am going to explain about Data Table manipulation techniques in asp.net ..it is one of the techinques used to take the query from the dataset..
For example if u have reterive data from table using dataset then use data in front end don’t go for other sql query for database

        
  protected void Page_Load(object sender, EventArgs e)
        {
            grddata.DataSource = registertable();
            grddata.DataBind();
          
        }

        public DataTable registertable()
        {
            dt = new DataTable();
            dt.Columns.Add("sno");
            dt.Columns.Add("name");
            dt.Columns.Add("salary");
            dt.Columns.Add("designation");
            dt.Rows.Add("1001", "sharth", "100000", "dotnet");
            dt.Rows.Add("1002", "ramesh", "40000", "java");
            dt.Rows.Add("1003", "rakesh", "100000", "testing");
            dt.Rows.Add("1004", "shiva", "100000", "java");

          
                DataTable dt2 = new DataTable();

                   dt2 = dt.Select("salary=100000").CopyToDataTable();

                   ViewState["datanew"] = dt2;
                   grddata2.DataSource = dt;
                   grddata2.DataBind();
                

                   return dt2;
          

           



              

        }

Tuesday, 2 December 2014

Wednesday, 12 November 2014

How to create Code First Insert/Update/Delete Stored Procedures



Creating stored procedure For Insert, Update, Delete, Find (search)

All friend in this article I am explain basic concept of creating store procedure in Sql Server .
Defination
1)In a database management system (DBMS), a stored procedure is a precompiled set of Structured Query Language (SQL) statements that can be shared by a number of programs.
2)Stored procedures must be called or invoked, as they are sets of SQL and programming commands that perform very specific functions. Most major relational database systems (e.g., SQL Server, Oracle, MySQL, Postgres and others) provide support for stored procedures.









<br/>----------------------------------------
Example for creating stored procedure

*) Creating Insert stored procedures for above fields.
create procedure insertdatanew
(@spfirstname varchar(30),@splastname varchar(30),@spemailid varchar(30),@spphonemo bigint,@sploaction varchar(30))
as
begin
insert into registrationdata values (@spfirstname,@splastname,@spemailid,@spphonemo,@sploaction)
end
*) Creating Delete stored procedures for above fields.
create procedure deletedata
@sno int
as
begin
delete * from registrationdata
end

GO
*) Creating Update stored procedures for above fields.


Create procedure gridupdatedata
@spsno int ,@spfirstname varchar(30),@splastname varchar(30),@spemailid varchar(30),@spphoneno varchar(30),@splocation varchar(30)
as
begin
update registrationdata set firstname=@spfirstname,lastname=@splastname,emailid=@spemailid,phoneno=@spphoneno,location=@splocation where sno=@spsno
end
go
*) How Creating select  * from  table stored procedures for above fields.

create procedure [dbo].[deletedata]
@sno int
as
begin
Select * from registrationdata where sno = @sno
end

GO