hello every1, really i need help on how i can make a login form that works and is connected to my database using ADO

my frmlogin is composed of 2 textbox (txtuser,txtpass)
and 2 command buttons (cmdlogin,cmdcancel)
and my database name is (MAINDB2)
inside MAINDB2 is (tblReg)
fields inside tblReg is (Username,Password)

and for example , field Username contains (tester)
, field Password contains (testpass)

and when i put (tester) in the txtuser
and (testpass) in the txtpass

i will do this

MAINMENU.show
unload me

-------------------------PLS HELP ME!!! =( --------------------------------

Check for existance of username and the corresponding password in database using SQL. Try to use count() . If it is 1 then login else prompt to enter the correct username and the corresponding password.

hi,

Follow the below instructions, if u hv any doubts u can ask me.
1) First set reference to use ADO Project Menu-> Reference-> Microsoft Activex Data Objects 2.6 Library
2) Create DSN Start-> Run->odbcad32->ADD

MS- Access
Select Microsoft Access Driver(*.mdb)-> Finish
type the name in Data Source Name
then select database by clicking select button
browse the database then press ok again press ok
DSN Created
Oracle
Select Microsoft ODBC for Oracle-> Finish
type the name in Data Source Name, username of oracle
and server name of oracle(i.e.host string)
then press ok
DSN Created

Sql Server
Select Sql Server-> Finish
type the name in Data Source Name
select the system name in server where your database is located
then press next select with Sql Server authentication
and unmark check box and give the username and password of your sql server
then press next select database press next finally click finish
DSN Created

3) Code
'write the code outside the procedure
Dim cn as new Adodb.connection
Dim rs as new Adodb.recordset
Private Sub Form_Load()
set cn = new adodb.connection
set rs = new adodb.recordset
'Accesscn.open "login",false
'Oraclecn.open "login","scott","tiger"
'Sql Server if password available give password
cn.open "login","sa",false
End Sub
Private Sub Command1_Click()
rs.open "select count(*) from login where username = '" & text1.text & "' and password = '" & text2.text & "'",cn,adopendynamic,adlockoptimistic
if rs(0)=0 then
msgbox "Unknown User"
else if rs(0)=1 then
MAINMENU.show
unload me
end if
End Sub

shailu:)

hello every1, really i need help on how i can make a login form that works and is connected to my database using ADO

my frmlogin is composed of 2 textbox (txtuser,txtpass)
and 2 command buttons (cmdlogin,cmdcancel)
and my database name is (MAINDB2)
inside MAINDB2 is (tblReg)
fields inside tblReg is (Username,Password)

and for example , field Username contains (tester)
, field Password contains (testpass)

and when i put (tester) in the txtuser
and (testpass) in the txtpass

i will do this

MAINMENU.show
unload me

-------------------------PLS HELP ME!!! =( --------------------------------

thx for the help!! appriciate it so much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.