Wrox Programmer Forums
|
BOOK: Beginning ASP.NET Dynamic Websites w/ Web Matrix
This is the forum to discuss the Wrox book Beginning Dynamic Websites: with ASP.NET Web Matrix by Dave Sussman, James Greenwood, Alex Homer, Colt Kwong, John M. West; ISBN: 9780764543746
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET Dynamic Websites w/ Web Matrix section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 28th, 2004, 08:39 PM
Authorized User
 
Join Date: Jun 2004
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey @bmains
what i'm trying to do u know when u asked to register at website and asked to choose a user name and then it come back user already exist!!! that is what i need the code for
in my case i used an existing user and then i tried to register with the same user AND THAT WHERE I NEED TO HAVE THE CODE TO TELL who ever is registering that user name u choose exist
by the way appreciated the help i get from this fourm big up to all
regards

 
Old July 28th, 2004, 08:47 PM
Authorized User
 
Join Date: Jun 2004
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by bmains
 Hey,

Yeah, that's it's inserting the name. Are you trying to login with that name, or register that name? Seems like something is crossing over here.

Brian
@bmains the code i posted is for the inserting method i use to register new user what i'm missing is that " how can i check what has been entered(userID0) already there
sorry if i confused any one
pls forgive me

 
Old July 29th, 2004, 07:37 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

What I did for my project was have a registration page and on the registration page check to see if the user exists and then insert if the user doesn't exist like this:

If checkIfUserExists() Then
' INSERT new user here

checkIfUserExists() returns true or false depending on if the username is in the DB or not.

then the login page checks to verify if the user exists and if the user was NOT in the DB it would say "The username and password were not found. Would you like to register?" and link to the registration page.

 
Old August 2nd, 2004, 07:26 PM
Authorized User
 
Join Date: Jun 2004
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i'm sorry but i think i'mthick when it come to writing code i'll put down the code i got for the simple registeration page and login one
@stu9820 i couldn't figure out how did u did that the login chk for the user
please could any one sen me a SAMPLE COD THAT WORKS so i can undersatnd how it work

his the register page code :

Sub Button1_Click(sender As Object, e As EventArgs)

insert(txtUserID.text, txtPass.text)

End Sub

    Function insert(ByVal userID As String, ByVal userPass As String) As Integer
        Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\Inetpub\Copy"& _
" of wwwroot\Ass.mdb"
        Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString )

        Dim queryString As String = "INSERT INTO [AssData] ([UserID], [UserPass]) VALUES (@UserID, @UserPass)"
        Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
        dbCommand.CommandText = queryString
        dbCommand.Connection = dbConnection

        Dim dbParam_userID As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_userID.ParameterName = "@UserID"
        dbParam_userID.Value = userID
        dbParam_userID.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_userID)
        Dim dbParam_userPass As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_userPass.ParameterName = "@UserPass"
        dbParam_userPass.Value = userPass
        dbParam_userPass.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_userPass)

        Dim rowsAffected As Integer = 0
        dbConnection.Open
        Try
            rowsAffected = dbCommand.ExecuteNonQuery
        Finally
            dbConnection.Close
        End Try

        Return rowsAffected
    End Function


this is the login page:

Sub LoginBtn_Click(Sender As Object, E As EventArgs)

    If Page.IsValid Then
        Dim UserDS As new system.data.dataset

        UserDS = GetUser(userName.text, userPass.text)
        if userDS.Tables(0).Rows.Count = 1 then
          FormsAuthentication.RedirectFromLoginPage(UserName .Text, true)
        Else
            Msg.Text = "Invalid Credentials: Please try again"

        end if
    End If

End Sub

    Function GetUser(ByVal userID As String, ByVal userPass As String) As System.Data.DataSet
        Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\Inetpub\Copy"& _
" of wwwroot\Ass.mdb"
        Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString )

        Dim queryString As String = "SELECT [AssData].* FROM [AssData] WHERE (([AssData].[UserID] = @UserID) AND ([Ass"& _
"Data].[UserPass] = @UserPass))"
        Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
        dbCommand.CommandText = queryString
        dbCommand.Connection = dbConnection

        Dim dbParam_userID As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_userID.ParameterName = "@UserID"
        dbParam_userID.Value = userID
        dbParam_userID.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_userID)
        Dim dbParam_userPass As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        dbParam_userPass.ParameterName = "@UserPass"
        dbParam_userPass.Value = userPass
        dbParam_userPass.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_userPass)

        Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter
        dataAdapter.SelectCommand = dbCommand
        Dim dataSet As System.Data.DataSet = New System.Data.DataSet
        dataAdapter.Fill(dataSet)

        Return dataSet
    End Function

by the way i would like to thank any one who help me
and hopefully soon i might be helping other people
regards to all






Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT Check if directory exist ArnArn XSLT 3 November 23rd, 2008 03:44 PM
values dont show up on ASP page but exist in DB msoul Classic ASP Basics 2 September 3rd, 2008 02:03 PM
How can I check whether a user is logged in or out rittwick PHP Databases 1 August 19th, 2007 04:47 PM
check for image field exist goldenstate ASP.NET 2.0 Basics 2 May 22nd, 2007 12:36 PM
How do I check a db before inserting a record? Lucy SQL Server ASP 3 April 25th, 2005 10:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.