• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

Custom login in asp.net 2.0 error

I decided to go against the custom membership provider that asp.net 2.0 provides and create my own login page using forms authentication ticket. However, when I run the code I get the following error:

Object must implement IConvertible

I've attempted to sort of convert 1.1 code into 2.0 code. I am decent at coding but by no means an expert at it.   I included my code here to hopefully see if anyone can tell me the error of my ways.

Please note that I don't have any desire to use the membership provider in asp.net 2.0 nor do I want to create a membership provider as I can't get that to work. I used to be fine with it in asp.net 1.1 just using the formsauthentication ticket. I think I can still do that in asp.net 2.0.

Thanks in advance for your help.
This is my button1_click event:
Dim breturn As Boolean
        breturn = verifyuser(loginname.Text, password.Text)
        If breturn = True Then
            Dim ticket As FormsAuthenticationTicket = New FormsAuthenticationTicket(loginname.Text, False, 5000)
            FormsAuthentication.RedirectFromLoginPage(loginname.Text, False)
        Else
            feedback.Text = "The Login Name and Password you typed in doesn't match our records"
 
        End If
 
This is my "verifiyuser" function:
Protected Function verifyuser(ByVal username As String, ByVal password As String) As Boolean
 
        Dim sdr As System.Data.SqlClient.SqlDataReader
        Dim con As SqlConnection = New SqlConnection("myconnectionstring)
        Dim breturn As Boolean
        Dim cmd As SqlCommand = New SqlCommand("login", con)
        cmd.CommandType = Data.CommandType.StoredProcedure
        cmd.Parameters.Add("@cologin", NVarChar, 255).Value = loginname
        cmd.Parameters("@cologin").Value = loginname
        con.Open()
        sdr = cmd.ExecuteReader
        While sdr.Read
            If sdr("Password") = password Then
                breturn = True
            End If
        End While
        Return breturn
    End Function
 
This is my stored Procedure:
 
@cologin as nvarchar (max)
	
	
AS
	select * from members where cologin = @cologin
	RETURN

Open in new window

0
smitty68521
Asked:
smitty68521
  • 2
1 Solution
 
harwantgrewalCommented:
Hi smitty68521
Have you gone through this URL ?
http://msdn.microsoft.com/en-us/library/aa480476.aspx
0
 
smitty68521Author Commented:
This helped a great deal. I was able to get the steps done correctly. Thanks a bunch.
0
 
harwantgrewalCommented:
Thanks smitty68521

Just for future alwasy try to search in Google first you will definately find answers there.
:)

Harry
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now