Problem with no data when using objReader.Read()

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2005
Posts: 1
Reputation: DiNo_r is an unknown quantity at this point 
Solved Threads: 0
DiNo_r DiNo_r is offline Offline
Newbie Poster

Problem with no data when using objReader.Read()

 
0
  #1
Jun 8th, 2005
Hi There,

I am very new to ASP.Net, just started to migrate this week.

I am also sorry if this question has been asked in the Forum already, i have searched but not found anything.

I am looking to pull some data from a database using the following code:


dim objCmd2 as OleDbCommand = new OleDbCommand("spSubPage", conn)
objCmd2.CommandType = CommandType.StoredProcedure
dim ObjReader2 as OleDbDataReader

objParam = objCmd2.Parameters.Add("@PageID", OleDbType.BSTR)
objParam.Direction = ParameterDirection.Input
objParam.Value = PageID

try
objCmd2.Connection.Open()
objReader2 = objCmd2.ExecuteReader()

dgSubPage.DataSource = objReader2
dgSubPage.DataBind()

objCmd2.Connection.Close()
catch ex as OleDbException
lblMessage.Text = "Sorry, there was an error"
end try


i am using a DataGrid to display the data.

This code is for a Content Management App where this query pulls out the sub page data and displayes the sub links on the right. Now, if there are no sublinks i dont want the sub link box to be displayed but i can't think of a way to do it in .Net, so i need some help. In asp this would be very simple, just using:


if not rsQuery.EOF
-- DISPLAY TABLE TOP --
while not rsQuery.EOF
-- DISPLAY SUB LINKS --
rsQuery.MoveNext
wend
--DISPLAY TABLE BASE
end if

but obviously this is not as efficient.

Look forward to hearing your suggestions, this (i think it will end up to be simple) task has been fustrating me for 2days now!

DiNo
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 26
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Problem with no data when using objReader.Read()

 
0
  #2
Jun 24th, 2005
if objReader2.Read() then
dgSubPage.DataSource = objReader2
dgSubPage.DataBind()
else
...
end if
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC