473,387 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Causes of 'Error:Invalid attempt to read when no data is present.' in VB .NET

Oodles Of Noodles
Hello fellow geeks
I have a problem in my database iVB .Net program that is generating 'Error:Invalid attempt to read when no data is present.'

The weird part is that when you call the page from another page the script works yielding the desired records

BUT WHEN YOU CALL THE SCRIPT AGAIN WHEN ATTEMPTING TO CALL THE SAME PAGE (PASSING DIFFERENT PARAMETERS USING QUERYSTRING ) THE QUERY DOESN'T YIELD ANY DATA

Expand|Select|Wrap|Line Numbers
  1. Sub PropertyView( )
  2.  
  3.     Dim objSQLDataReader As System.Data.SQLClient.SQLDataReader
  4.     Dim objSQLCommand As System.Data.SQLClient.SqlCommand
  5.     Dim objSQLConnection As System.Data.SQLClient.SQLConnection 
  6.  
  7.     Dim arrayPictures As New ArrayList
  8.     Dim arrayFeatures As New ArrayList
  9.  
  10.     Dim intPreviousStep    
  11.     Dim intNumberReturnedRecords
  12.     Dim strQS
  13.     Dim strQuery    
  14.  
  15.     Dim strAddress
  16.     Dim intBedNum
  17.     Dim intBathNum
  18.     Dim strCity        
  19.     Dim intCost        
  20.     Dim strCurrItem    
  21.     Dim strDescription
  22.     Dim strFeature
  23.  
  24.     Dim strLanLordId
  25.  
  26.     Dim intAccumulatorPicture As Integer    
  27.     Dim intAccumulatorFeature As Integer    
  28.     Dim strName    
  29.     Dim strPictureFileName
  30.     Dim strPropertyId
  31.     Dim strState       
  32.     Dim strSqFeet      
  33.     Dim strType
  34.     Dim intYearBuilt
  35.     Dim intZipCode   
  36.  
  37.     Dim strSQL    
  38.  
  39.     intPreviousStep = 0
  40.  
  41.     try    
  42.  
  43.         objSQLConnection = New System.Data.SQLClient.SQLConnection("???????????????????????????")
  44.         objSQLConnection.Open()
  45.         objSQLCommand = New System.Data.SQLClient.SqlCommand()
  46.         objSQLCommand.Connection = objSQLConnection
  47.  
  48.  
  49.         strPropertyId = Request.QueryString("PropertyId")
  50.         strSQL = "select * "
  51.         strQuery = "from Property WHERE PropertyId='" & strPropertyId & "'"
  52.  
  53.         objSQLCommand.CommandText = strSQL & strQuery
  54.         objSQLDataReader = objSQLCommand.ExecuteReader()
  55.  
  56.  
  57.         REM Only one record        
  58.         Rem if objSQLDataReader.Read()
  59.  
  60.         objSQLDataReader.Read()
  61.             strAddress     = objSQLDataReader("Address")
  62.             intBedNum      = objSQLDataReader("BedroomNum")
  63.             intBathNum     = objSQLDataReader("BathroomNum")
  64.             strCity        = objSQLDataReader("City")
  65.             intCost        = objSQLDataReader("Cost")
  66.             strDescription = objSQLDataReader("Description")
  67.             strLanLordId   = objSQLDataReader("LandLordID")
  68.             strName        = objSQLDataReader("Name")
  69.             strState       = objSQLDataReader("State")
  70.             strSqFeet      = objSQLDataReader("SqFeet")
  71.             strType        = objSQLDataReader("Type")
  72.             intZipCode     = objSQLDataReader("ZipCode")
  73.         rem End If    
  74.         objSQLDataReader.Close()    
  75.  
  76.  
  77.         strQuery = "from Pictures WHERE PropertyId='" & strPropertyId & "'"
  78.  
  79.         objSQLCommand.CommandText = strSQL & strQuery
  80.         objSQLDataReader = objSQLCommand.ExecuteReader()
  81.  
  82.         Dim boolean_
  83.  
  84.  
  85.         intAccumulatorPicture = 0
  86.  
  87.         boolean_ = true
  88.  
  89.         Dim temp
  90.         temp = objSQLDataReader.HasRows()
  91.  
  92.         if temp then
  93.             Response.Write("<br>01")
  94.         else
  95.             Response.Write("<br>00")
  96.         End If
  97.  
  98.         While boolean_            
  99.             If objSQLDataReader.Read() Then
  100.                 intAccumulatorPicture = intAccumulatorPicture + 1
  101.                 strPictureFileName = objSQLDataReader("PicFileName")
  102.                 arrayPictures.Add( strPictureFileName )
  103.             Else
  104.                 boolean_ = false
  105.             End If
  106.         End While        
  107.  
  108.  
  109.  
  110.  
  111.         objSQLDataReader.Close()        
  112.         strQuery = "from Features WHERE PropertyId='" & strPropertyId & "'"
  113.  
  114.         objSQLCommand.CommandText = strSQL & strQuery
  115.         objSQLDataReader = objSQLCommand.ExecuteReader()
  116.  
  117.  
  118.  
  119.  
  120.         intAccumulatorFeature = 0
  121.         boolean_ = true
  122.  
  123.         temp = objSQLDataReader.HasRows()
  124.  
  125.         if temp then
  126.             Response.Write("<br>11")
  127.         else
  128.             Response.Write("<br>10")
  129.         End If
  130.  
  131.         While boolean_
  132.  
  133.             If objSQLDataReader.Read() Then
  134.                 intAccumulatorFeature = intAccumulatorFeature + 1
  135.                 strFeature = objSQLDataReader("Feature")
  136.                 arrayFeatures.Add( strFeature )
  137.             Else
  138.                 boolean_ = false
  139.             End If
  140.  
  141.         End While                
  142.  
  143.         Response.Write( CStr(intAccumulatorPicture) )
  144.         Response.Write( "<br>" )
  145.         Response.Write( strPropertyId )
  146.         WritePropertyPhoto( strPropertyId, arrayPictures )
  147.  
  148.     catch
  149.         Response.Write("Error:" & err.Description)
  150.     Finally
  151.         objSQLDataReader = Nothing
  152.         objSQLCommand = Nothing
  153.         objSQLConnection.Close()
  154.         objSQLConnection = Nothing
  155.     End Try
  156. End Sub
  157.  
The URL of the offending page can be found at:
http://homestrategiessolutions.com/c...tyID=PSnh54fsi

The data is fetched on this page but when you click on Next or Prev the error occurs

THANX IN ADVANCE :D
Apr 12 '08 #1
1 1873
It was a simple mistake when calling Query string when i was copncatenating the parameters with ? instead that with & so multiple parameters merged into one., hence no records found

Thanx myself !
:)
Apr 12 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Frank Jones | last post by:
When manually running resgen.exe from the command prompt (Visual Studio .NET 2003 command prompt) I get the following error: error: Invalid ResX input. error: Specific exception:...
7
by: bazley | last post by:
I've been tearing my hair out over this: #ifndef MATRIX2_H #define MATRIX2_H #include <QVector> template<class T> class Matrix2 { public:
0
by: David Veeneman | last post by:
This post is for the Google archive and does not require a reply. I received an 'Invalid parameter used' error when trying to do double-buffering with the .Net SetStyles method. I used this code...
2
by: Matthew Louden | last post by:
I want to read how many records in the table, and insert a record with id field which increment the counter by 1. However, I had the following runtime on Dim s As Integer = CInt(dr("t")). Since "t"...
0
by: Bruce Skelton | last post by:
The vacuum of my db is failing with this error. postgres% ./vacuumdb.sh ERROR: Invalid UNICODE character sequence found (0xed5c30) vacuumdb: vacuum EventManager failed I don't understand...
4
by: muthu | last post by:
In the following code it gives the error "error: invalid operands to binary &" Why it is happening #include <signal.h> #include <errno.h> #define SIGBAD(signo) ((signo) <= 0 || (signo) >=...
5
by: Eric | last post by:
I run a program which read emails from a text file. There is some thing invalid in one or more text file. When program is busy doing parsing it shows that error and process stop. I dont know which...
7
by: The|Godfather | last post by:
Hi everybody, I read Scotte Meyer's "Effective C++" book twice and I know that he mentioned something specific about constructors and destructors that was related to the following...
0
by: pavankumar106 | last post by:
hi im trying to pass a stream to read the key in pgp . when im trying to get the keyrings by passing the stream its throwing a error invalid header encountered?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.