Results 1 to 3 of 3

Thread: I want login form code

  1. #1

    Thread Starter
    Junior Member DannyPatel's Avatar
    Join Date
    Jul 2015
    Posts
    24

    Smile I want login form code

    Hello everyone..

    I need login form code is there any one have then please give me ..

  2. #2
    Addicted Member masoudk1990's Avatar
    Join Date
    Nov 2013
    Location
    Persia
    Posts
    172

    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

  3. #3

    Thread Starter
    Junior Member DannyPatel's Avatar
    Join Date
    Jul 2015
    Posts
    24

    Re: I want login form code

    Quote Originally Posted by masoudk1990 View Post
    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
  •  



Click Here to Expand Forum to Full Width