Re: "Invalid attempt to FieldCount when reader is closed"
From: Sonali.NET[MVP] (xb_sonalix_at_hotmail.com)
Date: 03/16/04
- Next message: pitcher: "Datasource variable "supposedly" not declared ?!?"
- Previous message: Kostia: "Re: dataGrid dataview sorting/editing"
- In reply to: Harish Palaniappan: "Re: "Invalid attempt to FieldCount when reader is closed""
- Next in thread: Harish Palaniappan: "Re: "Invalid attempt to FieldCount when reader is closed""
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 16 Mar 2004 13:42:44 -0500
Try giving
da.Fill(ds,"Somename");
Also try closing the connection in finally block
"Harish Palaniappan" <harish@curans.co.in> wrote in message
news:#3SueZ3CEHA.3692@tk2msftngp13.phx.gbl...
> I am posting a portion of the code... as below.
>
> ;
> ;
> private method called on page_load
> ;
> ;
> ;
> code to create datagrid control and columns.
> ;
> ;
> //add cols to datagrid
> dg1.Columns.Add(PrjName);
> dg1.Columns.Add(PrjDesc);
> dg1.Columns.Add(PrjCheck);
> dg1.Columns.Add(PrjRights);
>
> //fill datagrid
> oConn.Open();
> oCmd.Connection=oConn;
> oCmd.CommandText="select prjname, prjdesc from projects";
>
> SqlDataAdapter da = new SqlDataAdapter(oCmd);
> DataSet ds = new DataSet();
> da.Fill(ds);
>
> oConn.Close();
>
> DataView dv = ds.Tables[0].DefaultView;
> dg1.DataSource=dv;
> dg1.DataBind(); ----------------------------------------> error occurs
> when executing this statement.
> return dg1;
>
> }//method end.
>
> 'Harish.
>
>
> "Sonali.NET[MVP]" <xb_sonalix@hotmail.com> wrote in message
> news:uYZHzR3CEHA.1588@tk2msftngp13.phx.gbl...
> > Can you post code
> >
> > "Harish Palaniappan" <harish@curans.co.in> wrote in message
> > news:#DcnZ62CEHA.3132@TK2MSFTNGP11.phx.gbl...
> > > Hi actually when does this error occur.. "Invalid attempt to
FieldCount
> > when
> > > reader is closed"
> > > and whats the solution..
> > >
> > > I dynamically created a datagrid.. with headers, and two custom
columns
> > one
> > > with check boxes.. and another with dropdown controls.. when i try to
do
> a
> > > datagrid1.databind(); . this error pops up..
> > >
> > > even sample code in books and websites have code similar to what i
have
> > > created.. but none of them have mentioned about this error.
> > >
> > >
> >
> >
>
>
- Next message: pitcher: "Datasource variable "supposedly" not declared ?!?"
- Previous message: Kostia: "Re: dataGrid dataview sorting/editing"
- In reply to: Harish Palaniappan: "Re: "Invalid attempt to FieldCount when reader is closed""
- Next in thread: Harish Palaniappan: "Re: "Invalid attempt to FieldCount when reader is closed""
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|