Pages

This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Saturday, 2 March 2013

Linq without DBML file




ASPX.CS Code

.CS Code (Class file)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Linq.Mapping;



[Table(Name = "stu_info")]
public class Person
{
    [Column(IsPrimaryKey = true, IsDbGenerated = true)]
    public int roll { get; set; }
    [Column]
    public string Name { get; set; }
    [Column]
    public string LName { get; set; }
}


ASPX CODE

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
    </div>
    <asp:GridView ID="GridView1" runat="server">
    </asp:GridView>
  
    </form>
</body>
</html>




using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Linq.Mapping;
using System.Data;
using System.Data.Linq;
using System.Data.SqlClient;


public partial class _Default : System.Web.UI.Page
{
    //BusinessObjects db = new BusinessObjects();
    public string constr = @"Data Source=RAMUTELECOM\RKUMAR;Initial Catalog=test3;Persist Security Info=True;User ID=sa;Password=mysachi";
    protected void Page_Load(object sender, EventArgs e)
    {

        DataContext db = new DataContext(constr);
       GridView1.DataSource = db.GetTable<Person>().ToList();
       GridView1.DataBind();
     
    
          
    }




    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(constr);
        SqlCommand com = new SqlCommand("exec sp_twotable", con);
        con.Open();
        SqlDataReader dr = com.ExecuteReader();
        GridView1.DataSource = dr;
        GridView1.DataBind();
        dr.NextResult();
        GridView2.DataSource = dr;
        GridView2.DataBind();
        con.Close();
    }
}

Sunday, 13 January 2013

What is Linq ?



What is Linq?
It is Language Integration Query.
If someone does not know about the syntax of SQL Server (working in SQL Environment). After understanding the syntax of LINQ they can easily work with Microsoft SQL Server .
Like: - Insert command, Select Command, Update Command and Delete Command.
In Linq we use var keyword to declare any object .
For example:-
Var obj=123;
Var objstring=”rahul Gupta” etc……
If we declare an object with var keyword then the object can store any type of Value.