Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object Not set to an instance of an object DataReader

Status
Not open for further replies.

Modica82

Technical User
Jan 31, 2003
410
GB
Hi all,

this code did work so i am a bit confused as to why all of a sudden it doesnt, can anyone see anything that i am missing. The error is with the while loop for the dataReader!

Code:
        Public Function GetQuotes(ByVal Customer As String) As GetQuotesResponse

            Dim quote As QuoteInfo
            Dim quoteCol As New QuoteInfoCollection
            Dim gqr As New GetQuotesResponse

            Dim reader As SqlDataReader

            'Grab Quotes
            reader = SqlHelper.ExecuteReader(ConfigurationSettings.AppSettings("ConnectionString"), _
                "CERULEAN_GetQuotes", Customer)

            While reader.Read

                quote = New QuoteInfo

                With quote
                    .CustomerCode = IIf(reader("Customer Code") Is DBNull.Value, String.Empty, reader("Customer Code"))
                    .Project = IIf(reader("Project") Is DBNull.Value, String.Empty, reader("Project"))
                    .ProjectDetail = IIf(reader("Project Detail") Is DBNull.Value, String.Empty, reader("Project Detail"))
                    .ProspectCode = IIf(reader("Prospect Code") Is DBNull.Value, String.Empty, reader("Prospect Code"))
                    .QuoteNo = IIf(reader("Quote No") Is DBNull.Value, String.Empty, reader("Quote No"))
                    .ProjectStatus = IIf(reader("Project Status") Is DBNull.Value, String.Empty, reader("Project Status"))
                    .RepCode = IIf(reader("Rep Code") Is DBNull.Value, String.Empty, reader("Rep Code"))
                    .YourRef = IIf(reader("Your Ref") Is DBNull.Value, String.Empty, reader("Your Ref"))
                    .EnteredBy = IIf(reader("Entered By") Is DBNull.Value, String.Empty, reader("Entered By"))
                End With

                quoteCol.Add(quote)

            End While

            reader.Close()

            gqr.Quotes = quoteCol

            Return gqr

        End Function

thanks,

Rob

---------------------------------------
 
is this a datareader virus? two posts today with the "All of a sudden" comment.

 
ha, i have had a lot of the all of the sudden syndrome today. Someone changed my connection string so the permissions to return data were not there, thats why i was getting these errors. Sorry for the post, not required in the end.

Rob

---------------------------------------
 
glad to hear its resolved and not an infection!

ill link the other post to here, maybe other post has same issue.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top