- Katılım
- 4 Mayıs 2007
- Mesajlar
- 3,644
- Excel Vers. ve Dili
- 2016 PRO TÜRKÇE-İNG. 64 BİT
DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
Altın Üyelik Hakkında Bilgi
Sub sira_no_ver()
Dosya = Application.GetOpenFilename("All Files (*.*),*.*.")
If Dosya = False Then
MsgBox "Veri alınacak dosyayı seçmediniz.", vbInformation, "DİKKAT"
Exit Sub
Else
End If
sifre = ""
'---------------------------------------------------------------------------------------
Dim Katalog As Object, Data3 As Object, Tablo As Object
Dim son1, son2
Set Data3 = CreateObject("ADODB.Connection")
Set Katalog = CreateObject("ADOX.Catalog")
Dim fL As Object
Set fL = CreateObject("Scripting.FileSystemObject")
yer3 = fL.GetBaseName(Dosya)
Uzanti = fL.GetExtensionName(Dosya)
If Uzanti = "xls" Or Uzanti = "xlsb" Or Uzanti = "xlsx" Or Uzanti = "xlsm" Then
Exit Sub
End If
'On Error Resume Next
If Uzanti = "mdb" Or Uzanti = "accdb" Then
If Uzanti = "mdb" Then
Data3.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & Dosya & ";Uid=Admin;Pwd=" & sifre & ";"
ElseIf Uzanti = "accdb" Then
'Data3.Open "Driver={Microsoft Access Driver (*.accdb)};Dbq=" & Dosya & ";Uid=Admin;Pwd=" & sifre & ";"
Data3.Open "Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=" & Dosya & ";Uid=Admin;Pwd=" & sifre & ";"
End If
Katalog.ActiveConnection = Data3
For Each Tablo In Katalog.Tables
If Tablo.Type = "TABLE" Then
Sayfa_adı = Tablo.Name
End If
Next
Data3.Close
Set Data3 = Nothing
Set Katalog = Nothing
End If
Dim Conn As New ADODB.Connection
Dim Cmd As New ADODB.Command
Dim Kayit As ADODB.Recordset
Set Kayit = CreateObject("adodb.recordset")
If Uzanti = "mdb" Then
baglan = "provider=microsoft.jet.oledb.4.0;data source=" & Dosya & ";User ID=admin;Jet OLEDB:Database Password=" & sifre
ElseIf Uzanti = "accdb" Then
baglan = "Provider=Microsoft.ACE.OLEDB.12.0;data source=" & Dosya & ";User ID=admin;Jet OLEDB:Database Password=" & sifre
End If
Kayit.Open "select * from " & Sayfa_adı, baglan, 3, 2
son2 = Kayit.RecordCount
Conn.Open baglan & ";" & "Persist Security Info=False"
Cmd.ActiveConnection = Conn
Cmd.CommandType = adCmdText
Cmd.CommandText = "Delete * from " & Sayfa_adı 'data" 'Or you could use the trunc commandsqlText
Set Kayit = Cmd.Execute
Kayit.Open "select * from " & Sayfa_adı, baglan, 3, 2
'On Error Resume Next
For r = 1 To Val(son2)
Kayit.AddNew
Kayit(0) = r
Kayit.Update
Next r
Kayit.Update
Kayit.Close
Set Kayit = Nothing
MsgBox "kayıt işlemi tamamdır"
'MsgBox "Silme işlemi tamamdır"
End Sub