Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

.NET Forum


You are currently viewing our .NET Forum as a guest. Please register to participate.
Login



Reply
ASP.NET User Registration
Old 07-25-2007, 06:01 PM ASP.NET User Registration
mb2000inc's Avatar
Super Talker

Posts: 140
Name: Mark
Location: Ohio
Trades: 0
Hey,

So I have this great new project on my lap (for those of you who helped me out previously, your suggestions both rocked and worked tremendously...)

So, here's the new one.

I have a web form where a user registers and I have everything set in place, BUT, I'm trying to check the database and see if that particular user already exists...and I'm trying to include it in a giant bit of code already in place.

Essentially, what I would like to see is:

IF user exists then message box (you already exist) else create user profile.

But I don't have the verbage quite down.... so does anyone happen to have the code handy to do that?

As always, any input would be helpful.
__________________
Need a vacation.
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
 
Register now for full access!
Old 07-26-2007, 11:08 AM Re: ASP.NET User Registration
mb2000inc's Avatar
Super Talker

Posts: 140
Name: Mark
Location: Ohio
Trades: 0
I forgot to mention that this is my code:
Code:
Try
SQLCommand2.CommandText = "Select email from testtable where email = '" & txtEmail.Text & "'"
userRS = SQLCommand.ExecuteNonQuery()
IfNot userRS.EOF Then
bolEmailFound = True
userRS.close()
MessageBox("This <b>E-Mail Address</b> Currently Exists In Our Database.<br/> Please Check The E-mail Address And Try Again.")
SQLCommand.Connection = SqlDataSource1
Else
bolEmailFound = "false"
userRS.Close()
userRS = Nothing
EndIf
Else
'SQL INSERT Command and variables
SQLCommand.CommandText = "usp_testtable_Insert '" & txtFirst.Text & "','" & txtLast.Text & "','" & txtEmail.Text & "','" & txtUserID.Text & "','" & CStr(rblGender.SelectedValue) & "','" & rblZodiac.SelectedValue & "','" & rblLiving.SelectedValue & "','" & dlfollowup.SelectedValue & "','" & rblReferredBy.SelectedValue & "','" & txtOther.Text & "'"
SQLCommand.Connection = SqlDataSource1
SQLCommand.ExecuteNonQuery()
EndIf
Catch Ex As Exception
'If there are errors in any coding this will tell us where and what line number to look for
MessageBox("There was an error trying to run the query.<br />" + Ex.Message + "<br /><i>" + Ex.StackTrace + "</i>")
EndTry
SqlDataSource1.Close()

What am I missing?
__________________
Need a vacation.

Last edited by mb2000inc; 07-26-2007 at 11:15 AM..
mb2000inc is offline
Reply With Quote
View Public Profile Visit mb2000inc's homepage!
 
Old 07-26-2007, 05:15 PM Re: ASP.NET User Registration
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
Trades: 0
The first thing I see is a call to ExecuteNonQuery() against a select statement. That one call is probably breaking your whole page; this method never returns data from the db to the caller. There are three methods on a SQL command, which all send the SQL down to the database, but differ in terms of results. NonQuery is meant for delete, update, or insert statements, where you want to do work, but not get info. Scalar is when you only want a single value, say if you call Select @@Identity right after an insert. And then just regular Execute does the work at the db, and gives your program access to whatever data is sent back.

MessageBox ... that renders to client script, no? I haven't used this in ASPx myself, so I'm not familiar with that one.

Last thing I noticed; I don't know what type of object userRS is, but ADO.NET dropped the concept of record sets. You can work with DataTables, DataSets ( which are collections of DataTables that can have relationships ), and DataReaders. For a query that only returns one row, it's not going to matter very much which you use, but as far as I know, you aren't able to use recordset style coding anymore. I could be wrong.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Reply     « Reply to ASP.NET User Registration
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.20953 seconds with 12 queries