a different case of retrieving SQL DB data for login form

ssfftt

Well-known member
Joined
Oct 27, 2005
Messages
163
Programming Experience
1-3
[RESOLVED]a different case of retrieving SQL DB data for login form

hi all:I am using VB.NET 2003i have a login form that contains btnLogin, txtLoginName.Text and txtLoginPW.Textalso have a SQL database table contains 2 columns : user and pwon the login frm, i have visually setup SqlDataAdapterUserLogin, SqlConnectionUserLogin and DataSetUserLogin, dont know if the settings are all correct though.I know somehow when i trigger btnLogin.click, i need to check whether the inputs match up database record, and then i either give access to valid user or deny access. However, i have no idea how to implement this by code.because i am new to VB.NET, can anyone please be more specific on code while trying to help?thanks
 
Last edited:
if i am still confusing u, would it be better for u to tell me if you were me, how would u start and do the whole thing?
 
Ok, now I'm up to speed with you. Your parameters are created in the form view. The examples were more dymanic.

SqlCommandUserLogin.Parameters("@UNAME").Value = txtLoginName.Text.Trim
SqlCommandUserLogin.Parameters("@PW").Value = txtLoginPW.Text.Trim

@UNAME and @PW name are whatever you assigned the ParameterName to be in the form view.
 
yes,thx god u eventually there :)
u want me to set them in code?
what about the paramaters i already set in the form view?
 
That should work for you, but... Since you asked, IMHO :)

I wouldn't use data access controls in the form view. It's really inflexible and can get hard to follow. Just my 2 cents.
 
Yes, those should be right before the executescalar in your login.click

The parameters you have are fine, just make sure they're the same (if your form view paramerters have "@" leading off, use themin the code I gave you; if not, leave them off).
 
[RESOLVED]thx sevenhalo, u awesome!

that was very very helpful time, appreciate it.

btw, can u plz recommand any online resources/materials for me to learn VB.NET?
 
I really enjoy this guy's webcast series. This is by no means a one stop shop, but it's a great resource. Make sure you do the homeworks he puts together. Things will make alot more sense. Honestly, I would only watch one webcast every week or two and look into the topics further. Otherwise, you're just going to have ALOT of canned knowledge, but no opener. :)

http://www.microsoft.com/events/series/modernsoftdev.mspx

The VB.Net series is at the bottom.
 
I don't know exactly what you have at the moment but you need to CREATE the parameters in the designer but you cannot SET their values until run time. How could you set the values at design time when they aren't entered by the user until run time? In the Properties window for the SqlCommand object you create the two parameters and set the names to appropraite vales, which is usually the name of the database column preceded by "@". Then in your code you set the parameter values like this each time you want to check a login:
VB.NET:
myCommand.Parameters("@UserID").Value = userIDText.Text
myCommand.Parameters("@Password").Value = passwordText.Text
and then execute the command.

May I recommend that if some one suggests using a class that you are unfamiliar with, the first thing you should do is go to the help/MSDN topic for that class and read about it and its members. Here are some good resources:

http://www.homeandlearn.co.uk/NET/vbNet.html
http://www.startvbdotnet.com/
http://visualbasic.about.com/od/learnvbnet/
http://samples.gotdotnet.com/quickstart/
 
Back
Top