Last post Oct 06, 2008 07:30 AM by Mikesdotnetting
Oct 05, 2008 04:41 PM|nick.jackson25|LINK
This is my first ever post on a forum, so bare with me. If I forget to leave anything out please let me know! And If I put it in the wrong place let me know....and tell me what to do about it! [;)]
I have setup a Visual Web Developer Project and have setup an Access Database, which in aim will create my own login database system. This is a simple version of what I hope to achieve but it proves the point.
I want to be able check the database and see the availability of the email address before creating an account. ie - is the email address already in the system?
I hope this can be done by using the 'email_TextChanged' event with AutoPostBack enabled. Then desirably a Label beside the email textbox displays "This Email Address is already in use"
I have tried to explain it as best as I can. But if you dont understand, I will try and do it again.
Many Thanks, Nick
Here is the script I have used to write to the database from an aspx form and also Read the information using the grid view and Repeater. I did this by using this script I found on the Web. (This Works!)
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadLoadData()End SubPrivate Sub btnInsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsert.ClickDim cmd As New OleDbCommand("INSERT INTO Customers (FirstName, Email)VALUES('" & txtFirstName.Text & "','" & email.Text & "')", New OleDbConnection(strConn))cmd.Connection.Open()cmd.ExecuteNonQuery()cmd.Connection.Close()LoadData()End SubSub LoadData()Dim strSQL As String = "Select * From Customers"Dim cmd As New OleDbCommand(strSQL, New OleDbConnection(strConn))cmd.Connection.Open()Repeater1.DataSource = cmd.ExecuteReaderRepeater1.DataBind()cmd.Connection.Close()cmd.Connection.Dispose()End SubEnd Class
Visual Web Developer 2008 Express Edition
access insert data database new
Oct 05, 2008 06:07 PM|rtpHarry|LINK
Hey, just want to say straight off the bat that asp.net support authentication, membership, profiles, sessions, and a whole suite of login, lost password, create user controls so you can set this whole thing up without actually writing one line of code.
If you want to validate input then asp.net has custom validators which will let you do database lookups and check if a email is taken in your database (or the asp.net membership database). These are fired when the textbox loses focus or submit is pressed
which reduces the amount of loops and fails you would get otherwise as the user is typing the first half of their email address.
Oct 05, 2008 06:15 PM|nick.jackson25|LINK
Yeah, Ok Brill..
The biggest problem I had with the membership that is provided with asp.net is that I dont want to use a seperate username, I wanted the email address to be the username. If that makes sense?
Is there a way to do that using asp.net membership?
I have also read into changing the complicated password that is default to asp.net membership, is that easy to do and is it advised?
Oct 06, 2008 04:28 AM|rtpHarry|LINK
1, yes yes can have any name you like for username including email address - you just need to customize your CreateUserWizard a bit.
I'm sure there are more details step by step tutorials that will help you set this up. Here's one in fact:
Oct 06, 2008 07:30 AM|Mikesdotnetting|LINK
Not the greatest idea - using an email address as a password, then telling users that the one they chose is valid....
Nevertheless, before inserting the values, you should run a command such as SELECT COUNT(*) AS TheCount FROM Users WHERE FirstName = ? AND Email = ? . The return value will be either 0 or greater then 0 (if there are any matching rows). Depending on that,
you can show an error message, or insert the values as per your business logic.
The ? marks are parameter markers. You must use those instead of concatenating values directly into SQL thaty came from users. More help here:
The second one shows how the SELECT Count(*) thing works in a slightly different scenario, but you should get the idea.