PC Review


Reply
Thread Tools Rate Thread

Dataset code...is this correct?

 
 
John Pether
Guest
Posts: n/a
 
      28th Jul 2003
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


 
Reply With Quote
 
 
 
 
Kathleen Dollard
Guest
Posts: n/a
 
      30th Jul 2003
John,

* Line 92: Dim plusView As NEW DataView

(VB will fix the casing )

--
Kathleen (MVP-VB)



"John Pether" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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()
>
>



 
Reply With Quote
 
tperovic
Guest
Posts: n/a
 
      30th Jul 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" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> John,
>
> * Line 92: Dim plusView As NEW DataView
>
> (VB will fix the casing )
>
> --
> Kathleen (MVP-VB)
>
>
>
> "John Pether" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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()
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataSet.WriteXML() time zone not correct ron.skufca@sbcglobal.net Microsoft ADO .NET 1 28th May 2008 08:04 AM
Re: Correct way of using OleDbDataAdapter and DataSet to update Access database? JoWilliam Microsoft ADO .NET 0 8th Jan 2007 04:12 PM
is this dataset table select correct" GS Microsoft VB .NET 2 27th Oct 2006 04:03 AM
The correct syntax for returning a DataSet martinharvey via DotNetMonster.com Microsoft ASP .NET 2 25th Oct 2005 10:02 AM
UpdateCommand not returning correct value to DataSet joanneshovelton@yahoo.co.uk Microsoft ADO .NET 1 17th May 2005 11:36 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:56 AM.