Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 31st, 2006, 04:11 PM
Authorized User
 
Join Date: Sep 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Email Register for Updates

Hi

I am currently studying the Beginning ASP.NET 1.1 with VB.NET 2003 but getting in a muddle one part of the code in Chapter 11, I am getting an error of BC30311: Value of type 'System.Data.IDataReader' cannot be converted to 'Integer'.

Here is the line in question that this is refering to: -

Function CheckEmailAddress(ByVal emailAddress As String) As Boolean


    Dim connectionString As String = _
        ConfigurationSettings.AppSettings("ConnectionStrin g")
    Dim dbConnection As System.Data.IDbConnection = _
        New System.Data.OleDb.OleDbConnection(connectionString )

    Dim queryString As String = "SELECT COUNT([Newsletter].[EmailAddress])" & _
        "FROM [Newsletter] WHERE ([Newsletter].[EmailAddress] = @EmailAddress)"
    Dim dbCommand As System.Data.IDbCommand = _
        New System.Data.OleDb.OleDbCommand
        dbCommand.CommandText = queryString
        dbCommand.Connection = dbConnection

    Dim dbParam_emailAddress As System.Data.IDataParameter = _
        New System.Data.OleDb.OleDbParameter
        dbParam_emailAddress.ParameterName = "@EmailAddress"
        dbParam_emailAddress.Value = emailAddress
        dbParam_emailAddress.DbType = System.Data.DbType.[String]
        dbCommand.Parameters.Add(dbParam_emailAddress)
    Dim Result As Integer = 0

        dbConnection.Open

        Try
            Result = dbCommand.ExecuteReader
        Finally
            dbConnection.Close
        End Try

        If Result > 0 Then
            Return True
        Else
            Return False
        End If

End Function

The line in red is showing the error. Why is this error being generated?

Thanks

Sharon


 
Old October 31st, 2006, 04:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there.. result is an integer.. maybe you where looking for executescalar that only return a value??? execute reader returns a datareader ;)

HTH

Gonzalo
 
Old October 31st, 2006, 04:25 PM
Authorized User
 
Join Date: Sep 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ahh, many thanks, not sure why this is in the book I am studying wrong then?

Thanks

Sharon
 
Old October 31st, 2006, 04:29 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

could be.. if it is a wrox book look for the errata that's is on the main page.. ;)

HTH

Gonzalo





Similar Threads
Thread Thread Starter Forum Replies Last Post
Updates? GeekyMonkey BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X 12 May 24th, 2006 12:11 PM
Check if user is registered for email updates brettdalldorf ASP.NET 1.0 and 1.1 Basics 4 July 8th, 2005 10:01 AM
Handle Email UPdates sanjeet General .NET 0 February 2nd, 2005 05:18 PM
Email Updates from Excel pstaffeld Excel VBA 1 August 20th, 2003 07:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.