Advertisement
Guest User

sesalodbc01

a guest
Jul 9th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub test()
  2.    
  3.     ' On Error Resume Next
  4.  
  5. Const adOpenStatic = 3
  6. Const adLockOptimistic = 3
  7. Const adCmdText = &H1
  8.  
  9. Set objConnection = CreateObject("ADODB.Connection")
  10. Set objRecordset = CreateObject("ADODB.Recordset")
  11.  
  12. objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  13.     "Data Source=\\POEL5-DATEN\Altona-Büro-Dateien\11 Büroteam\Joe Koenig\Excel Übungen\Kunden.xlsx;" & _
  14.         "Extended Properties=""Excel 8.0;HDR=Yes;"";"
  15.  
  16. ' objRecordset.Open "Select * from [Tabelle2$] where farbe is not null ", objConnection, adOpenStatic, adLockOptimistic, adCmdText
  17.  
  18. 'objRecordset.Open "Select farbe, count(*) from [Tabelle2$] group by farbe having count(*) > 2 ;", _
  19. '               objConnection, adOpenStatic, adLockOptimistic, adCmdText
  20.  
  21.  
  22. objRecordset.Open "SELECT  KdID, sum(Umsatz) from [Kunden$] INNER JOIN [Umsatz$] on [Kunden$].KdID=[Umsatz$].Kundennummer group by KdID ", _
  23.                objConnection, adOpenStatic, adLockOptimistic, adCmdText
  24.  
  25.  
  26. Dim i As Integer
  27. i = 0
  28.  
  29. ' objRecordset.EOF And
  30.  
  31. Debug.Print "----------------------------------------------------------------------"
  32.  
  33. Do While Not objRecordset.EOF
  34.     ' Debug.Print objRecordset.Fields.Item(0) ' & " ; " & objRecordset.Fields.Item(1)
  35.    For Each fld In objRecordset.Fields
  36.         Debug.Print fld.Value;
  37.     Next
  38.     Debug.Print
  39.     'komma unterstrich
  40. '        objRecordset.Fields.Item("Number")
  41.    objRecordset.MoveNext
  42.    
  43.     i = i + 1
  44.    
  45. Loop
  46.  
  47. Debug.Print "--------------- " & Now() & " -------------------------"
  48.  
  49. objRecordset.Close
  50. objConnection.Close
  51.  
  52. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement