Hey all

I have a mdb file. I need to use this file as a datasource to display in the gridview.
Can anyone suggest me how to use a LINQ to add to that gridview.
here the purpose of gridview is simply to display some rows.......


Regards,
Prasanth.

Recommended Answers

All 5 Replies

define DataContext with connection string , write a queyr and bind result with gridview like below :

DataContext dc = new DataContext("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\Microsoft Access Database\\Microsoft Data Access\\test1.mdb");

Var data = from t in dc.your table name
           Select t;
Gridview1.DataSource = data;
Gridview1.DataBind();

Hey all

I have a mdb file. I need to use this file as a datasource to display in the gridview.
Can anyone suggest me how to use a LINQ to add to that gridview.
here the purpose of gridview is simply to display some rows.......


Regards,
Prasanth.

Hey Rohand,
thanks for ur reply..
can u send me the code in C# pls...

regards,
Prasanth.


define DataContext with connection string , write a queyr and bind result with gridview like below :

DataContext dc = new DataContext("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\Microsoft Access Database\\Microsoft Data Access\\test1.mdb");

Var data = from t in dc.your table name
           Select t;
Gridview1.DataSource = data;
Gridview1.DataBind();

always welcome... this is the C# code.. you can use it..

Hey Rohand,
thanks for ur reply..
can u send me the code in C# pls...

regards,
Prasanth.

To store the data in linq using this syntex

var database =
        from colomn in tables
        where condition
        select condition;

then
Bind the data using Linq Data Source.

protected void Page_Load(object sender, EventArgs e)
   	{
        GridView1.Visible = true;
        if (!IsPostBack)
        {
            GridView1.DataSource = LinqDataSource1;
            GridView1.DataBind();
        }
    	}

Hey ciint
thnk u soo much..
i got my problem solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.