•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 391,774 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,359 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 5676 | Replies: 1
![]() |
•
•
Join Date: Oct 2004
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
I really need your help on it.My application is supposed to capture every single user input and store in session variable session("MyCat") in the form of datatable. When page is first loaded, datatable will be initiated and session created. And all subsequent user input will be added in session("MyCat") by adding new rows. My code is as below:
Sub Page_Load(Sender as Object, e as EventArgs)
if NOT IsPostBack then
Dim dTable as DataTable
dTable = New DataTable("mySearch")
dTable.Columns.Add("catagory", System.Type.getType("System.String"))
dTable.Columns.Add("keyword", System.Type.getType("System.String"))
dTable.Columns.Add("ID", System.Type.getType("System.Int32"))
dTable.Columns("ID").AutoIncrement=True
session("myCat")= dTable
end if
end sub
Sub Submit(Sender As Object, e As EventArgs)
dTable=session("myCat")
dim dr as DataRow=dTable.NewRow()
dr(0)=Listbox1.SelectedItem.value
dr(1)=tbtext.Text
dTable.Rows.Add(dr)
session("myCat")= dTable
Anyway, system captures error when
dim dr as DataRow=dTable.NewRow()
is executed.Error message is
ystem.NullReferenceException: Object reference not set to an instance of an object
Can any more offer me help on it and let me know if there is any better solution for it...
Sub Page_Load(Sender as Object, e as EventArgs)
if NOT IsPostBack then
Dim dTable as DataTable
dTable = New DataTable("mySearch")
dTable.Columns.Add("catagory", System.Type.getType("System.String"))
dTable.Columns.Add("keyword", System.Type.getType("System.String"))
dTable.Columns.Add("ID", System.Type.getType("System.Int32"))
dTable.Columns("ID").AutoIncrement=True
session("myCat")= dTable
end if
end sub
Sub Submit(Sender As Object, e As EventArgs)
dTable=session("myCat")
dim dr as DataRow=dTable.NewRow()
dr(0)=Listbox1.SelectedItem.value
dr(1)=tbtext.Text
dTable.Rows.Add(dr)
session("myCat")= dTable
Anyway, system captures error when
dim dr as DataRow=dTable.NewRow()
is executed.Error message is
ystem.NullReferenceException: Object reference not set to an instance of an objectCan any more offer me help on it and let me know if there is any better solution for it...
Ok, this is the problem
You can't do this per say.
dTable=session("myCat")
but what you shoul do is this:
dTable=CStr(session("myCat"))
You need to convert it to a string. dTable is not set to anything recognizable (as the error message states).
Hope this helps!
*Note* Please use the CODE brackets when displaying several lines of code.
You can't do this per say.
dTable=session("myCat")
but what you shoul do is this:
dTable=CStr(session("myCat"))
You need to convert it to a string. dTable is not set to anything recognizable (as the error message states).
Hope this helps!
*Note* Please use the CODE brackets when displaying several lines of code.
Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
- session variable error (PHP)
- calling session variable (ASP.NET)
- Session Variable clashing (ASP.NET)
- Losing session variable problem...help! (ASP)
- session variable undefined in MX 6.1, works in CF 5 (ColdFusion)
- Session variable (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: looking for downloading asp.net/sqql2000 erp software
- Next Thread: Getting data from ASP page A to ASP page B using javascript


Linear Mode