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
- Sub PropertyView( )
- Dim objSQLDataReader As System.Data.SQLClient.SQLDataReader
- Dim objSQLCommand As System.Data.SQLClient.SqlCommand
- Dim objSQLConnection As System.Data.SQLClient.SQLConnection
- Dim arrayPictures As New ArrayList
- Dim arrayFeatures As New ArrayList
- Dim intPreviousStep
- Dim intNumberReturnedRecords
- Dim strQS
- Dim strQuery
- Dim strAddress
- Dim intBedNum
- Dim intBathNum
- Dim strCity
- Dim intCost
- Dim strCurrItem
- Dim strDescription
- Dim strFeature
- Dim strLanLordId
- Dim intAccumulatorPicture As Integer
- Dim intAccumulatorFeature As Integer
- Dim strName
- Dim strPictureFileName
- Dim strPropertyId
- Dim strState
- Dim strSqFeet
- Dim strType
- Dim intYearBuilt
- Dim intZipCode
- Dim strSQL
- intPreviousStep = 0
- try
- objSQLConnection = New System.Data.SQLClient.SQLConnection("???????????????????????????")
- objSQLConnection.Open()
- objSQLCommand = New System.Data.SQLClient.SqlCommand()
- objSQLCommand.Connection = objSQLConnection
- strPropertyId = Request.QueryString("PropertyId")
- strSQL = "select * "
- strQuery = "from Property WHERE PropertyId='" & strPropertyId & "'"
- objSQLCommand.CommandText = strSQL & strQuery
- objSQLDataReader = objSQLCommand.ExecuteReader()
- REM Only one record
- Rem if objSQLDataReader.Read()
- objSQLDataReader.Read()
- strAddress = objSQLDataReader("Address")
- intBedNum = objSQLDataReader("BedroomNum")
- intBathNum = objSQLDataReader("BathroomNum")
- strCity = objSQLDataReader("City")
- intCost = objSQLDataReader("Cost")
- strDescription = objSQLDataReader("Description")
- strLanLordId = objSQLDataReader("LandLordID")
- strName = objSQLDataReader("Name")
- strState = objSQLDataReader("State")
- strSqFeet = objSQLDataReader("SqFeet")
- strType = objSQLDataReader("Type")
- intZipCode = objSQLDataReader("ZipCode")
- rem End If
- objSQLDataReader.Close()
- strQuery = "from Pictures WHERE PropertyId='" & strPropertyId & "'"
- objSQLCommand.CommandText = strSQL & strQuery
- objSQLDataReader = objSQLCommand.ExecuteReader()
- Dim boolean_
- intAccumulatorPicture = 0
- boolean_ = true
- Dim temp
- temp = objSQLDataReader.HasRows()
- if temp then
- Response.Write("<br>01")
- else
- Response.Write("<br>00")
- End If
- While boolean_
- If objSQLDataReader.Read() Then
- intAccumulatorPicture = intAccumulatorPicture + 1
- strPictureFileName = objSQLDataReader("PicFileName")
- arrayPictures.Add( strPictureFileName )
- Else
- boolean_ = false
- End If
- End While
- objSQLDataReader.Close()
- strQuery = "from Features WHERE PropertyId='" & strPropertyId & "'"
- objSQLCommand.CommandText = strSQL & strQuery
- objSQLDataReader = objSQLCommand.ExecuteReader()
- intAccumulatorFeature = 0
- boolean_ = true
- temp = objSQLDataReader.HasRows()
- if temp then
- Response.Write("<br>11")
- else
- Response.Write("<br>10")
- End If
- While boolean_
- If objSQLDataReader.Read() Then
- intAccumulatorFeature = intAccumulatorFeature + 1
- strFeature = objSQLDataReader("Feature")
- arrayFeatures.Add( strFeature )
- Else
- boolean_ = false
- End If
- End While
- Response.Write( CStr(intAccumulatorPicture) )
- Response.Write( "<br>" )
- Response.Write( strPropertyId )
- WritePropertyPhoto( strPropertyId, arrayPictures )
- catch
- Response.Write("Error:" & err.Description)
- Finally
- objSQLDataReader = Nothing
- objSQLCommand = Nothing
- objSQLConnection.Close()
- objSQLConnection = Nothing
- End Try
- End Sub
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