PDA

Click to See Complete Forum and Search --> : MS Access Problems


§tudz
Dec 2nd, 2003, 05:03 AM
Hi,

I am writing a website, and I am using MS Access DBs
DB Name:
puzzlepirates.mdb

tables:
tbl_Users

fields:
Username
Password

******************************************

I want to retreive the value of the password, the SQL would be

"SELECT Password FROM tbl_Users WHERE USERNAME = " txt_Username.text

This would be a string value I know, but how do I execute it? and check it against txt_Password.txt?

I can retreive data from another table in the DB and add it to a datagrid with the following code, but I have no idea how to get just the password?


Dim MyConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & _
server.mappath("puzzlepirates.mdb"))
Dim CommandText As String = "Select Name, Title, Rank from alchemist_guild"

Dim myCommand As New OleDBCommand(CommandText, myConnection)

myConnection.Open()

DGAlchemist.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
DGAlchemist.DataBind()



any help?

Thanks

nswan
Dec 2nd, 2003, 08:09 AM
use this as a rough guide as i've not checked it

Dim MyConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & _
server.mappath("puzzlepirates.mdb"))
Dim CommandText As String = "SELECT Password FROM tbl_Users WHERE USERNAME = ' " & txt_Username.text & "' "


Dim myCommand As New OleDBCommand(CommandText, myConnection)
Dim myDataReader as oledbDataReader
myConnection.Open()

myDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)

if myDataReader.read then
'the user can be authenticated
end if


hope it helps!

Nick

§tudz
Dec 2nd, 2003, 09:20 AM
thanks for that, but you were 5mins too late lol
I just worked it out using oledbAdpater :)

But thanks all the same,

Maybe you can answer my other post:
Other POST (http://www.vbforums.com/showthread.php?s=&threadid=268406)


Thanks again