ok, I am trying to make one call to the db and create a datalist and then
populate a datalist and a datagrid with different filtered versions of the
dataset. I presume this is a better way of doing it than making two seperate
calls to the db where I could just use 2 stored procs to filter the data.
Any help or advice if I'm doing it the wrong way would be appreciated.

' Obtain Link information from Links table

Dim links As New DNSite.LinksDB()

Dim myDS As DataSet

myDS = links.GetLinks(CatID)

' filter dataset for premier links

' and bind to the datalist control

plusdl.DataSource = myDS.Tables("tblLinks").Select("TypeName = Premier
Plus")

plusdl.DataBind()

' bind remaining links to DataGrid

premierDG.DataSource = myDS.Tables("tblLinks").Select("TypeName <> Premier
Plus")

premierDG.DataBind()

-----------------------------------
I get the following error:
-----------------------------------

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:

Line 88: ' and bind to the datalist control
Line 89:
Line 90: plusdl.DataSource =
myDS.Tables("tblLinks").Select("TypeName = Premier")
Line 91: plusdl.DataBind()

Source File: **********\DNSLinks.ascx.vb Line: 90

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
ASPNetPortal.DNSLinks.BindGrid() in ********\DNSLinks.ascx.vb:90
ASPNetPortal.DNSLinks.Page_Load(Object sender, EventArgs e) in
********\DNSLinks.ascx.vb:76
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Control.LoadRecursive() +92
System.Web.UI.Control.LoadRecursive() +92
System.Web.UI.Control.LoadRecursive() +92
System.Web.UI.Page.ProcessRequestMain() +724

Re: Dataset code...is this correct? by Kathleen

Kathleen
Tue Jul 29 18:35:47 CDT 2003

John,

* Line 92: Dim plusView As NEW DataView

(VB will fix the casing )

--
Kathleen (MVP-VB)



"John Pether" <john@john.com> wrote in message
news:enPEy3RVDHA.2096@TK2MSFTNGP11.phx.gbl...
> Ok I am now using the datview as suggested but get the following error:
> Exception Details: System.NullReferenceException: Object reference not set
> to an instance of an object.
>
> Source Error:
> Line 91: plusTable = myDS.Tables("tblLinks")
> Line 92: Dim plusView As DataView
> Line 93: plusView = plusTable.DefaultView
> Line 94: plusView.RowFilter = "TypeName = Premier Plus"
> Line 95:
> Source File: ******\DNSLinks.ascx.vb Line: 93
> Stack Trace:
> [NullReferenceException: Object reference not set to an instance of an
> object.]
> DNSite.DNSLinks.BindGrid() in ******\DNSLinks.ascx.vb:93
> DNSite.DNSLinks.Page_Load(Object sender, EventArgs e) in
> ******\DNSLinks.ascx.vb:76
> System.Web.UI.Control.OnLoad(EventArgs e) +67
> System.Web.UI.Control.LoadRecursive() +29
> System.Web.UI.Control.LoadRecursive() +92
> System.Web.UI.Control.LoadRecursive() +92
> System.Web.UI.Control.LoadRecursive() +92
> System.Web.UI.Page.ProcessRequestMain() +724
>
> ---------------------
> The code is below:
> ---------------------
>
> <code>
> ' Obtain Link information from Links table
>
> Dim links As New DSN.LinksIndexDBbak()
>
> Dim myDS As DataSet
>
> myDS = links.GetLinks(CatID)
>
> ' filter dataset for premier plus links
>
> ' and bind to the datalist control
>
> Dim plusTable As DataTable
>
> plusTable = myDS.Tables("tblLinks")
>
> Dim plusView As DataView
>
> plusView = plusTable.DefaultView
>
> plusView.RowFilter = "TypeName = Premier Plus"
>
> plusdl.DataSource = plusView
>
> plusdl.DataBind()
>
> ' filter dataset for remaining links
>
> ' and bind to the datalist control
>
> Dim basicTable As DataTable
>
> basicTable = myDS.Tables("tblLinks")
>
> Dim basicView As DataView
>
> basicView = basicTable.DefaultView
>
> basicView.RowFilter = "TypeName = Basic, Premier"
>
> premierDG.DataSource = plusView
>
> premierDG.DataBind()
>
>



Re: Dataset code...is this correct? by tperovic

tperovic
Wed Jul 30 09:29:09 CDT 2003

Judging by the error message, I would say that the variable "plusTable" on
line 93 is Nothing which means that your dataset does not contain a table
called "tblLinks".

"Kathleen Dollard" <kathleen@mvps.org> wrote in message
news:#PNBkoiVDHA.2164@TK2MSFTNGP10.phx.gbl...
> John,
>
> * Line 92: Dim plusView As NEW DataView
>
> (VB will fix the casing )
>
> --
> Kathleen (MVP-VB)
>
>
>
> "John Pether" <john@john.com> wrote in message
> news:enPEy3RVDHA.2096@TK2MSFTNGP11.phx.gbl...
> > Ok I am now using the datview as suggested but get the following error:
> > Exception Details: System.NullReferenceException: Object reference not
set
> > to an instance of an object.
> >
> > Source Error:
> > Line 91: plusTable = myDS.Tables("tblLinks")
> > Line 92: Dim plusView As DataView
> > Line 93: plusView = plusTable.DefaultView
> > Line 94: plusView.RowFilter = "TypeName = Premier Plus"
> > Line 95:
> > Source File: ******\DNSLinks.ascx.vb Line: 93
> > Stack Trace:
> > [NullReferenceException: Object reference not set to an instance of an
> > object.]
> > DNSite.DNSLinks.BindGrid() in ******\DNSLinks.ascx.vb:93
> > DNSite.DNSLinks.Page_Load(Object sender, EventArgs e) in
> > ******\DNSLinks.ascx.vb:76
> > System.Web.UI.Control.OnLoad(EventArgs e) +67
> > System.Web.UI.Control.LoadRecursive() +29
> > System.Web.UI.Control.LoadRecursive() +92
> > System.Web.UI.Control.LoadRecursive() +92
> > System.Web.UI.Control.LoadRecursive() +92
> > System.Web.UI.Page.ProcessRequestMain() +724
> >
> > ---------------------
> > The code is below:
> > ---------------------
> >
> > <code>
> > ' Obtain Link information from Links table
> >
> > Dim links As New DSN.LinksIndexDBbak()
> >
> > Dim myDS As DataSet
> >
> > myDS = links.GetLinks(CatID)
> >
> > ' filter dataset for premier plus links
> >
> > ' and bind to the datalist control
> >
> > Dim plusTable As DataTable
> >
> > plusTable = myDS.Tables("tblLinks")
> >
> > Dim plusView As DataView
> >
> > plusView = plusTable.DefaultView
> >
> > plusView.RowFilter = "TypeName = Premier Plus"
> >
> > plusdl.DataSource = plusView
> >
> > plusdl.DataBind()
> >
> > ' filter dataset for remaining links
> >
> > ' and bind to the datalist control
> >
> > Dim basicTable As DataTable
> >
> > basicTable = myDS.Tables("tblLinks")
> >
> > Dim basicView As DataView
> >
> > basicView = basicTable.DefaultView
> >
> > basicView.RowFilter = "TypeName = Basic, Premier"
> >
> > premierDG.DataSource = plusView
> >
> > premierDG.DataBind()
> >
> >
>
>