Solved

Custom login in asp.net 2.0 error

Posted on 2008-10-12
3
235 Views
Last Modified: 2013-11-07
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
Comment
Question by:smitty68521
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
harwantgrewal earned 500 total points
ID: 22699921
Hi smitty68521
Have you gone through this URL ?
http://msdn.microsoft.com/en-us/library/aa480476.aspx
0
 
LVL 1

Author Closing Comment

by:smitty68521
ID: 31505478
This helped a great deal. I was able to get the steps done correctly. Thanks a bunch.
0
 
LVL 5

Expert Comment

by:harwantgrewal
ID: 22700000
Thanks smitty68521

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

Harry
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question