chetiserve

Untitled

Jun 1st, 2014
591
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.99 KB | None | 0 0
  1. Public Function Test()
  2.  
  3.      ' connection and recordset variables
  4.     Dim rstEmployees As ADODB.Recordset
  5.     Dim Cnxn As ADODB.Connection
  6.     Dim strSQLEmployees As String
  7.     Dim strCnxn As String
  8.     ' array variable
  9.     Dim arrEmployees As Variant
  10.     ' detail variables
  11.     Dim strMessage As String
  12.     Dim intRows As Integer
  13.     Dim intRecord As Integer
  14.    
  15.     ' open connection
  16.     Set Cnxn = New ADODB.Connection
  17.     strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _
  18.         "Initial Catalog='Pubs';Integrated Security='SSPI';"
  19.     Cnxn.Open strCnxn
  20.    
  21.     ' open recordset client-side to enable RecordCount
  22.     Set rstEmployees = New ADODB.Recordset
  23.     strSQLEmployees = "SELECT fName, lName, hire_date FROM Employee ORDER BY lName"
  24.     rstEmployees.Open strSQLEmployees, Cnxn, adOpenStatic, adLockReadOnly, adCmdText
  25.    
  26.     /* elaborate recordset */
  27.     rstEmployees.Close
  28.     Cnxn.Close
  29.     Set rstEmployees = Nothing
  30.     Set Cnxn = Nothing
  31. End Test
Advertisement
Add Comment
Please, Sign In to add comment