how to retrieve data from database using table adapters

vanisri

Member
Joined
Mar 12, 2007
Messages
6
Programming Experience
Beginner
hi

My program contains some parts as only registered user only can access.
so i have created a data base of registered users.
In my program first the users have to login.
For this they have to enter user name and password.
what ever data they have entered in the text box ,i have to compare the data with the data base.
can i use Table adapters?
Is there any Other way to get it done?

bye
 
hi,

You could use a sql query to count the number of records with the matching username and password. If the count = 0 then not validated else validated.

The sql query could be like this:

SELECT COUNT(*)
FROM USERINFO
WHERE (USERNAME = ? AND PASSWORD = ?)
 
that's the basic idea! of course you can use tableadapters; its the easiest way too.. take a read of the DW2 link in my sig, there should be a section on writing a scalar query (query that only returns one value such as the count() that ashish has presented)
 
hi

i could not get by using sql query.
so i hav tried in the following way

my program goes like this
after entering the user id and password when I ckilck Login button i have written the following Code .when i hav entered the user name and password are correct .even then i am getting "u r not a regitered user".where i am wrong.



//this is in the button click event
adap =
New SqlDataAdapter("select * from Password", con)

adap.Fill(ds,
"Password")
For r = 0 to ds.Tables["Password"].Rows.Count - 1 step 1
if tb1.Text == ds.Tables["Password"].Rows[r].ItemArray[0].ToString())then
if tb2.Text == ds.Tables["Password"].Rows[r].ItemArray[1].ToString() then
MsgBox("u r a valid user")
Else
MsgBox("u hav entered incorrect password")
End If
Else
MsgBox("u r not a registered user")
End If
Next

thank u
bye
 
read the dw2 link in my signature, section on "creating a form to search data" - that's what youre doing; you search their username and password. no results = bad login. 1 result = ok login
 
Back
Top