Error: No default member found???

G

Guest

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
 
T

Teemu Keiski

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::.. said:
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!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top