Guest User

Untitled

a guest
Jan 17th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. Sub Connection() ' create the connection
  2.  
  3. loginstatus = True
  4. login.Show
  5. Password = login.password_input
  6. user = login.UserName
  7.  
  8.  
  9. Dim con As ADODB.Connection
  10. Dim stored_procedure As String
  11. Dim ADODBCmd As ADODB.Command
  12. Dim rs As ADODB.Recordset
  13.  
  14.  
  15.  
  16. Set con = New ADODB.Connection
  17.  
  18. 'provide and create connection string
  19. Dim connectionString As String
  20.  
  21. Dim location As String 'the server
  22.  
  23. location = "MyLocation"
  24.  
  25. connectionString = "Provider=SQLOLEDB; Network Library=DBMSSOCN;Data Source=" & location & ";Command Timeout=0;Connection Timeout=0;Packet Size=4096; Initial Catalog=ukmc; User ID=" & user & "; Password=" & Password & ";"
  26.  
  27. 'handle when it is not possible to log in
  28. On Error GoTo ConnectionError
  29.  
  30. con.Open connectionString
  31. loginstatus = False
  32. Exit Sub
  33.  
  34.  
  35. 'errorhandl0
  36. ConnectionError:
  37. MsgBox "Not possible to log in. Have you entered the correct password?"
  38.  
  39. 'recordset - the data extracted
  40. Set ADODBCmd = New ADODB.Command
  41.  
  42. End Sub
Add Comment
Please, Sign In to add comment