hi there,
i am having problem with my codes. im getting this error,
'Name 'reader' is not declared'. please help.

[B]reader = con2.ExecuteReader()[/B]

[B] reader.Read [/B]


Protected Function SiteSpecificAuthenticationMethod(ByVal UserName As String, ByVal Password As String) As Boolean

        Dim log_statement As String = "SELECT * FROM [user] where username='" & UserName & "' and password='" & Password & "'"

        Dim con2 As System.Data.SqlClient.SqlCommand
        Dim con1 As System.Data.SqlClient.SqlConnection

        con1 = New System.Data.SqlClient.SqlConnection(SqlDataSource1.ConnectionString)
        con1.Open()

        con2 = New System.Data.SqlClient.SqlCommand(log_statement, con1)
        [B]reader = con2.ExecuteReader()[/B]

        If[B] reader.Read [/B]Then

            Return True

        Else

            Return False

        End If

    End Function

Recommended Answers

All 4 Replies

Hi There

Pls. see the code that uses reader

You can assign data to sql reader

Public Function CheckRequest(ByVal response As String) As Boolean
        Dim reader As SqlDataReader
        Try
            reader = SqlHelper.ExecuteReader(objConnection, "CheckRequest", RequestName)
            If reader.HasRows Then
                reader.Close()
                objConnection.Close()
                Return True
            Else
                reader.Close()
                objConnection.Close()
                Return False
            End If

        Catch ex As Exception

            objConnection.Close()
        End Try

    End Function
reader = con2.ExecuteReader()

try this:

Dim reader As SqlDataReader
reader = con2.ExecuteReader()

or:

Dim reader As SqlDataReader = con2.ExecuteReader()

they are correct..

they are correct..

Have you solved your problem? if you have so flag this thread as solved!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.