-
Aug 1st, 2015, 11:54 PM
#1
Thread Starter
Junior Member
I want login form code
Hello everyone..
I need login form code is there any one have then please give me ..
-
Aug 2nd, 2015, 12:20 AM
#2
Addicted Member
Re: I want login form code
This is how I handle this. You may get some errors from this codes because I just wrote them and didnt execute them.
Code:
'declare connection object
Dim myConnection As ADODB.Connection
Set myConnection = New ADODB.Connection
'declare command object
Dim Cmd As ADODB.Command
Set Cmd = New ADODB.Command
'declare a record set to store fetched values from database
Dim rs As ADODB.Record
'give your connection string to connection object and open it
myConnection .ConnectionString = "DSN=Pubs;UID=MyUserName;PWD=MyPassword;"
myConnection .Open
Cmd.ActiveConnection = myConnection
Cmd.CommandType = adCmdText
Cmd.CommandText = "SELECT 1 FROM User WHERE UserName = ? AND Password = ?"
Cmd.Parameters.Append Cmd.CreateParameter(, adVarChar, adParamInput, 20, txtUserName.Text)
Cmd.Parameters.Append Cmd.CreateParameter(, adVarChar, adParamInput, 20, txtPassword.Text)
Set rs = Cmd.Execute
If (rs.RecordCount > 0) Then
formMain.Show
formLogin.Visible = False
Else
Msgbox "Wrong user name or password"
End If
Computer Enterprise Masoud Keshavarz
For more information contact masoudk1990@yahoo.com
-
Aug 2nd, 2015, 01:08 AM
#3
Thread Starter
Junior Member
Re: I want login form code
Originally Posted by masoudk1990
This is how I handle this. You may get some errors from this codes because I just wrote them and didnt execute them.
Code:
'declare connection object
Dim myConnection As ADODB.Connection
Set myConnection = New ADODB.Connection
'declare command object
Dim Cmd As ADODB.Command
Set Cmd = New ADODB.Command
'declare a record set to store fetched values from database
Dim rs As ADODB.Record
'give your connection string to connection object and open it
myConnection .ConnectionString = "DSN=Pubs;UID=MyUserName;PWD=MyPassword;"
myConnection .Open
Cmd.ActiveConnection = myConnection
Cmd.CommandType = adCmdText
Cmd.CommandText = "SELECT 1 FROM User WHERE UserName = ? AND Password = ?"
Cmd.Parameters.Append Cmd.CreateParameter(, adVarChar, adParamInput, 20, txtUserName.Text)
Cmd.Parameters.Append Cmd.CreateParameter(, adVarChar, adParamInput, 20, txtPassword.Text)
Set rs = Cmd.Execute
If (rs.RecordCount > 0) Then
formMain.Show
formLogin.Visible = False
Else
Msgbox "Wrong user name or password"
End If
Thanks You So Much...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|