Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
1.83/5 (6 votes)
See more:
any one solve these errors given below

C#
Line 31:         dset = new DataSet();
Line 32:         adsource = new PagedDataSource();
Line 33:         dadapter.Fill(dset);
Line 34:         adsource.DataSource = dset.Tables[0].DefaultView;
Line 35:         adsource.PageSize = 3;


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


public partial class Default2 : System.Web.UI.Page
{
    SqlDataAdapter dadapter;
    DataSet dset;
    PagedDataSource adsource;
    string connstring = "server=.......;user id=sa;password=.....;database=IMADB";
    int pos;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.ViewState["vs"] = 0;
        }
        pos = (int)this.ViewState["vs"];
        databind();
    }

    private void databind()
    {
        dadapter = new SqlDataAdapter("select * from IMADB_tbluser", connstring);
        dset = new DataSet();
        adsource = new PagedDataSource();
        dadapter.Fill(dset);
        adsource.DataSource = dset.Tables[0].DefaultView;
        adsource.PageSize = 3;
        adsource.AllowPaging = true;
        adsource.CurrentPageIndex = pos;
        btnfirst.Enabled = !adsource.IsFirstPage;
        btnprevious.Enabled = !adsource.IsFirstPage;
        btnlast.Enabled = !adsource.IsLastPage;
        btnnext.Enabled = !adsource.IsLastPage;
        GridView1.DataSource = adsource;
        GridView1.DataBind(); 
        
    }             
    

    protected void btnfirst_Click(object sender, EventArgs e)
    {
        pos = 0;
        databind();
    }
    protected void btnprevious_Click(object sender, EventArgs e)
    {
        pos = (int)this.ViewState["vs"];
        pos += 1;
        this.ViewState["vs"] = pos;
        databind();
    }
    protected void btnnext_Click(object sender, EventArgs e)
    {
        pos = (int)this.ViewState["vs"];
        pos += 1;
        this.ViewState["vs"] = pos;
        databind();
    }
    protected void btnlast_Click(object sender, EventArgs e)
    {
        pos = adsource.PageCount-1;
            databind();
    }
}
Posted
Updated 27-Jan-12 3:22am
v2
Comments
Herman<T>.Instance 27-Jan-12 9:21am    
which errors?
priyanka999 27-Jan-12 9:23am    
dadapter.Fill(dset);
CPallini 27-Jan-12 9:24am    
That's not an error. That is a statement.
Herman<T>.Instance 27-Jan-12 9:25am    
he means he get's an error when that line is executed
priyanka999 27-Jan-12 9:25am    
Invalid object name 'IMADB_tbluser'.

I don't see an sqlconnection that gets opened and closed
 
Share this answer
 
Comments
priyanka999 27-Jan-12 9:34am    
i gived connections again it gets error
If you are getting "Invalid object name 'IMADB_tbluser" as you say in your comment, then you likely have a valid db connection, but you need to check on the table name "IMADB_tbluser". From the look of this name, I suspect that the name of your table is in fact "tbluser" and that you need to remove the other part from your sql. Your db connection should be opening the IMADB database already, so this may work. It's only a shot in the dark because you haven't really given us a lot to go on.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900