Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Connection() ' create the connection
- loginstatus = True
- login.Show
- Password = login.password_input
- user = login.UserName
- Dim con As ADODB.Connection
- Dim stored_procedure As String
- Dim ADODBCmd As ADODB.Command
- Dim rs As ADODB.Recordset
- Set con = New ADODB.Connection
- 'provide and create connection string
- Dim connectionString As String
- Dim location As String 'the server
- location = "MyLocation"
- 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 & ";"
- 'handle when it is not possible to log in
- On Error GoTo ConnectionError
- con.Open connectionString
- loginstatus = False
- Exit Sub
- 'errorhandl0
- ConnectionError:
- MsgBox "Not possible to log in. Have you entered the correct password?"
- 'recordset - the data extracted
- Set ADODBCmd = New ADODB.Command
- End Sub
Add Comment
Please, Sign In to add comment