Help with No default member error!!!

G

Guest

Can some one please tell me why I'm getting this error! I have been told it is because there is no true or false being returned but I'm not sure how to correct this! I would be really grateful for any advice!


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

..:: Stored Procedure ::..

CREATE PROCEDURE ValidateUser
(
@UserName nvarchar (255),
@Password nvarchar (255)
)
AS
SELECT Count(*)
AS Num_of_Users
FROM tblUsers
WHERE usrName = @UserName AND usrPassword = @Password;


GO
 
D

Donald E. Hurley Jr.

Function DBConnection() As Boolean

and you also want to return false if the login doesn't suceed.

Hope this helps.

Tim::.. said:
Can some one please tell me why I'm getting this error! I have been told
it is because there is no true or false being returned but I'm not sure how
to correct this! I would be really grateful for any advice!
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

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top