944,068 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 3850
  • ASP.NET RSS
Jun 8th, 2005
0

Problem with no data when using objReader.Read()

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
DiNo_r is offline Offline
1 posts
since Jun 2005
Jun 24th, 2005
0

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

if objReader2.Read() then
dgSubPage.DataSource = objReader2
dgSubPage.DataBind()
else
...
end if
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: prblem:use a control in datagrid
Next Thread in ASP.NET Forum Timeline: Error while building asp.net solution





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC