Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old December 29th, 2005, 07:50 AM
Authorized User
Points: 285, Level: 5
Points: 285, Level: 5 Points: 285, Level: 5 Points: 285, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: , , .
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your going to love me. Unfortunately this still does not work. (Although to be honest I really thought it would do). Here is the current code.

Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim strPatNum As String = Request.QueryString("PatNum")
cnBarwickPas.Open()
Dim cmdPatsNextKin As New Odbc.OdbcCommand("SELECT ASSETCOM.MASTER5.MSMROL, ASSETCOM.NEXTKIN.NKMROLL, ASSETCOM.NEXTKIN.NKTITLE, ASSETCOM.NEXTKIN.NKFOREN, ASSETCOM.NEXTKIN.NKSURNM, ASSETCOM.NEXTKIN.NKADDR1, ASSETCOM.NEXTKIN.NKADDR2, ASSETCOM.NEXTKIN.NKADDR3, ASSETCOM.NEXTKIN.NKADDR4, ASSETCOM.NEXTKIN.NKPOST7, ASSETCOM.NEXTKIN.NKPHONE, ASSETCOM.NEXTKIN.NKRELAT FROM ASSETCOM.MASTER5, ASSETCOM.NEXTKIN WHERE ASSETCOM.MASTER5.MSMROL = ASSETCOM.NEXTKIN.NKMROLL AND ASSETCOM.MASTER5.MSMROL =" & strPatNum, cnBarwickPas)
Dim drPatsNextKin As Odbc.OdbcDataReader
drPatsNextKin = cmdPatsNextKin.ExecuteReader()
lblTitleSts.Text = drPatsNextKin.GetString(drPatsNextKin.GetOrdinal("NKTITLE"))
lblTitleSts.DataBind()
drPatsNextKin.Close()
cnBarwickPas.Close()

End Sub
This error I receive is:
Code:
No data exists for the row/column. 
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.InvalidOperationException: No data exists for the row/column.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


[InvalidOperationException: No data exists for the row/column.]
   System.Data.Odbc.OdbcDataReader.internalGetString(Int32 i) +425
   System.Data.Odbc.OdbcDataReader.GetString(Int32 i) +5
   DDHPAS.WebForm7.Page_Load(Object sender, EventArgs e) +170
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +731
So I thought i would double check in SQL that there is data regarding that PatNum and there is, I also double checked to make sure that strPatNum was receiving the value from the query string request and it is.

As soon as I it tries to process this line "lblTitleSts.Text = drPatsNextKin.GetString(drPatsNextKin.GetOrdinal(" NKTITLE"))" thats when it falls over.

I also tried it with the "rPatsNextKin = cmdPatsNextKin.ExecuteReader(CommandBehavior.Singl eRow)" as well.
Reply With Quote
  #12 (permalink)  
Old December 29th, 2005, 08:05 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

A few things you can try:

1. Write out the complete SQL statement before you execute the reader. Then paste it in the query designer of your database and see if it works.

2. Remove the WHERE clause from your SQL. Then you can see what happens when you get a result set.

3. Check for HasRows to see if the reader returned a row before you try to access its data.

BTW, there is no need to call DataBind() on the label. Setting its Text property directly is enough.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #13 (permalink)  
Old December 29th, 2005, 08:07 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Oh, and make sure you use the check for DBNull.Value I showed you earlier. Maybe there is a record, but the column you're trying to access is empty (null).

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #14 (permalink)  
Old January 16th, 2006, 05:37 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

I have the similiar problem.
I'm using datareader (let's call it dr) to retrieve data from MS-SQL
and also receive an "No data exists for the row/column" error
when using dr.IsDBNull(0) method???

1. I've checked that datareader object contains data (dr.HasRows is true)
2. Other methods like dr.GetString(0) or dr.GetDataType(0) works fine!!!
3. But... using dr.IsDBNull(0) raises an error!!!

What may be the reason?
This issue is CRITICAL for me.

HELP please,
Helena
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rows 2 Columns kilika Oracle 0 October 14th, 2005 01:16 PM
Columns To Rows alyeng2000 SQL Language 2 March 11th, 2005 03:08 PM
Data Report: Columns Against Rows bemular VB How-To 0 January 6th, 2005 12:52 AM
Rows into columns shamsad Oracle 0 April 7th, 2004 04:38 AM



All times are GMT -4. The time now is 09:53 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.