Error: No default member found???

Discussion in 'ASP .Net' started by =?Utf-8?B?VGltOjouLg==?=, Jul 8, 2004.

  1. Can some one please tell me why I'm getting this error! I presume it is because there is something wrong with my Database connection but am not really sure what!

    Thanks

    ...:: Error ::..
    System.MissingMemberException: No default member found for type 'Boolean'.


    ...:: CODE ::..
    Private Sub cmdSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSubmit.Click
    If Page.IsValid Then
    'Connect to Database for User Validation
    If DBConnection(txtUserName.Text, txtPassword.Text) Then
    FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, False) ' ||||| default.aspx Page!

    Else
    ' Credentials are Invalid
    lblMessage.Text = "Invalid Login!"
    End If
    End If
    End Sub
    Function DBConnection()


    Dim Myconn As New SqlConnection(ConfigurationSettings.AppSettings("strConn"))
    Dim cmd As New SqlCommand("ValidateUser", Myconn)
    cmd.CommandType = CommandType.StoredProcedure

    Dim objParam1, objParam2 As SqlParameter

    objParam1 = cmd.Parameters.Add("@UserName", SqlDbType.Char)
    objParam2 = cmd.Parameters.Add("@Password", SqlDbType.Char)

    objParam1.Direction = ParameterDirection.Input
    objParam2.Direction = ParameterDirection.Input

    objParam1.Value = txtUserName.Text
    objParam2.Value = txtPassword.Text

    Try
    If MyConn.State = ConnectionState.Closed Then
    MyConn.Open()
    End If

    Dim objReader As SqlDataReader
    objReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)

    While objReader.Read()
    If CStr(objReader.GetValue(0)) <> "1" Then
    lblMessage.Text = "Invalid Login!"
    Else
    objReader.Close()
    Return True
    End If

    End While
    Catch ex As Exception
    lblMessage.Text = "Error Connecting to Database!"
    End Try

    End Function
     
    =?Utf-8?B?VGltOjouLg==?=, Jul 8, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?VGltOjouLg==?=

    Teemu Keiski Guest

    Hi,

    have you made sure that your method returns False if there is a problem and
    when the user shouldn't be able to log? It doesn't seem to explicitly return
    False in any situation which it needs to do because the return value is
    evaluated in If statement.

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist
    http://blogs.aspadvice.com/joteke




    "Tim::.." <myatix_at_hotmail.com> wrote in message
    news:...
    > Can some one please tell me why I'm getting this error! I presume it is

    because there is something wrong with my Database connection but am not
    really sure what!
    >
    > Thanks
    >
    > ..:: Error ::..
    > System.MissingMemberException: No default member found for type 'Boolean'.
    >
    >
    > ..:: CODE ::..
    > Private Sub cmdSubmit_Click(ByVal sender As System.Object, ByVal e As

    System.EventArgs) Handles cmdSubmit.Click
    > If Page.IsValid Then
    > 'Connect to Database for User Validation
    > If DBConnection(txtUserName.Text, txtPassword.Text) Then
    >

    FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, False) '
    ||||| default.aspx Page!
    >
    > Else
    > ' Credentials are Invalid
    > lblMessage.Text = "Invalid Login!"
    > End If
    > End If
    > End Sub
    > Function DBConnection()
    >
    >
    > Dim Myconn As New

    SqlConnection(ConfigurationSettings.AppSettings("strConn"))
    > Dim cmd As New SqlCommand("ValidateUser", Myconn)
    > cmd.CommandType = CommandType.StoredProcedure
    >
    > Dim objParam1, objParam2 As SqlParameter
    >
    > objParam1 = cmd.Parameters.Add("@UserName", SqlDbType.Char)
    > objParam2 = cmd.Parameters.Add("@Password", SqlDbType.Char)
    >
    > objParam1.Direction = ParameterDirection.Input
    > objParam2.Direction = ParameterDirection.Input
    >
    > objParam1.Value = txtUserName.Text
    > objParam2.Value = txtPassword.Text
    >
    > Try
    > If MyConn.State = ConnectionState.Closed Then
    > MyConn.Open()
    > End If
    >
    > Dim objReader As SqlDataReader
    > objReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
    >
    > While objReader.Read()
    > If CStr(objReader.GetValue(0)) <> "1" Then
    > lblMessage.Text = "Invalid Login!"
    > Else
    > objReader.Close()
    > Return True
    > End If
    >
    > End While
    > Catch ex As Exception
    > lblMessage.Text = "Error Connecting to Database!"
    > End Try
    >
    > End Function
     
    Teemu Keiski, Jul 8, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy Eshtry
    Replies:
    2
    Views:
    4,315
    Teemu Keiski
    Feb 14, 2004
  2. mazda_88
    Replies:
    0
    Views:
    1,425
    mazda_88
    Jun 7, 2004
  3. tshad

    No default member found

    tshad, Feb 8, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,886
    tshad
    Feb 8, 2006
  4. Andy Eshtry

    Error: No default member found for type MyClass

    Andy Eshtry, Feb 13, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    199
    Andy Eshtry
    Feb 13, 2004
  5. Rob
    Replies:
    1
    Views:
    214
Loading...

Share This Page