DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Public DB As ADODB.Connection
Public RS As ADODB.Recordset
Public SQLStr As String
Sub DBON()
On Error Resume Next
Set DB = New ADODB.Connection
Mypath = "C:\Deneme\veri.xls" 'Dosya Yolu
Set FSO = CreateObject("Scripting.FileSystemObject")
kontrol = FSO.FileExists(Mypath)
If kontrol = False Then
MsgBox "Kaynak Dosya Bulunamadı.", 64, "UYARI"
Set DB = Nothing
Set FSO = Nothing
Exit Sub
Else
DB.Open "Driver={Microsoft Excel Driver (*.xls)}; DBQ=" & Mypath
End If
Set FSO = Nothing
End Sub
Sub DBOFF()
On Error Resume Next
DB.Close
Set DB = Nothing
End Sub
Sub RSON()
On Error Resume Next
Set RS = New ADODB.Recordset
RS.CursorLocation = adUseClient
RS.CursorType = adOpenDynamic
RS.LockType = adLockOptimistic
End Sub
Sub RSOFF()
On Error Resume Next
RS.Close
Set RS = Nothing
End Sub
Sub KayitBul()
On Error Resume Next
DBON
RSON
Range("b2:c2").ClearContents
SQLStr = "SELECT COUNT([Doğum Yeri]),SUM([Yaş]) FROM [DATA$] WHERE [Doğum Yeri]='" & [a2] & "'"
RS.Open SQLStr, DB
[b2].Value = RS.Fields(0)
[c2].Value = RS.Fields(1)
[a1].Select
RSOFF
DBOFF
End Sub
[color=Green]'Referanslardan "Microsoft ActiveX Data Object X.X Library" seçili olmalıdır.[/color]