• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

Veri tabanı kodundaki hata

Katılım
6 Mart 2009
Mesajlar
133
Excel Vers. ve Dili
office 2007
Private Sub CommandButton2_Click()
Set bağlan = CreateObject("Adodb.Connection")
baglan.provider = "Microsoft.jet.OLEDB.4.0"
baglan.Open = "C:\ogrenci.mdb"
End Sub
 
Yanlış olan soruyu sorma biçiminiz !! . ğ kullanmayın!!
 
Son düzenleme:
Bu şekilde kullanabilirsiniz;
Kod:
Private Sub CommandButton2_Click()
    Dim baglan as object
    Set baglan = CreateObject("adodb.connection")
    baglan.Open "provider=microsoft.jet.oledb.4.0;data source=C:\ogrenci.mdb"
    Set baglan = Nothing
End Sub

Ya da referanslardan ActiveX Data Object 2.x'i seçerek bu şekilde kullanabilirsiniz;
Kod:
Private Sub CommandButton2_Click()
    Dim baglan As ADODB.Connection
    Set baglan = New ADODB.Connection
    baglanti = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\ogrenci.mdb"
    baglan.Open baglanti
    Set baglan = Nothing
End Sub
MsgBox baglan.State satırı ile de bağlantıyı kontrol edebilirsiniz.

0 bağlantı yok
1 bağlantı var
 
sayın snx111 formda yeni değilim sadece acelem olduğu için böyle sordum hatamız olduysa kusuruma bakmayın.
sayın murat bey ikisi de olmadı acaba access de mi bir sorun var?
 
Hata verdi mi ? Verdiyse ne hatası verdi ?

En güzeli dosyanızı gönderin bir bakalım...
 
ogrenci veritabanını c içerisine yerleştiriyorum
öğrencitakibi excel kitabım içerisin de userform1 var yeni kayıt düğmesine kodu yerleştiriyorum.
teşekkürler
 

Ekli dosyalar

Private Sub CommandButton2_Click()
Set baglan = CreateObject("Adodb.Connection")
baglan.provider = "Microsoft.jet.OLEDB.4.0"
baglan.Open = "C:\ogrenci.mdb"
End Sub
 
Sn.snx111, bazı mesajlarınız hiç hoş değil.
Benim mesaj yazdığım konulara bu tarz mesajlar yazmamanızı rica ediyorum.

Sn.wolwaren, resim seçme ve veritabanına kaydetme ile ilgili gerekli işlemleri yaptım.
Ekteki mdb dosyasını "C" sürücüsü içine atın ve Excel dosyasındaki TIKLA btunona basarak bir deneyin...


Kodlar şu şekildedir;
Kod:
Private Sub UserForm_Initialize()
    Dim con As Object, rs As Object
    Set con = CreateObject("adodb.connection")
    dosya = "C:\ogrenci.mdb"
    con.Open "provider=microsoft.jet.oledb.4.0;data source=" & dosya
    Set rs = con.Execute("select * from ogrenci_tablo Order By id")
    With ListBox1
        .Clear
        .ColumnCount = 6
        .ColumnWidths = "20;50;60;60;60;0"
        .Column = rs.GetRows
        Label5.Caption = .ListCount
    End With
    Set rs = Nothing: Set con = Nothing
End Sub
Kod:
Private Sub CommandButton1_Click()
    Application.EnableEvents = False
    yol = MsgBox("Seçim Yapılsın mı ?", vbYesNo, Application.UserName)
    If yol = vbNo Then Exit Sub
    If yol = vbYes Then
        evn = Application.GetOpenFilename(Filefilter:="Resim Dosyaları,*.jpg;*.bmp", Title:="Resim Seçimi")
    If evn = False Then Exit Sub
        TextBox5.Text = evn
        Image1.Picture = LoadPicture(TextBox5.Value)
    End If
    Application.EnableEvents = True
End Sub
Kod:
Private Sub CommandButton2_Click()
    Dim evn As Object, rs As Object
    Set evn = CreateObject("adodb.connection")
    dosya = "C:\ogrenci.mdb"
    evn.Open "provider=microsoft.jet.oledb.4.0;data source=" & dosya
    Set rs = CreateObject("adodb.recordset")
    rs.Open "select * from ogrenci_tablo", evn, 1, 3
    rs.addnew
        rs.fields("isim").Value = TextBox1.Value
        rs.fields("soyisim").Value = TextBox2.Value
        rs.fields("kursu").Value = TextBox3.Value
        rs.fields("bitistarihi").Value = TextBox4.Value
        rs.fields("Resim").Value = TextBox5.Value
    rs.Update
    MsgBox "Bilgiler veritabanına kaydedilmiştir. ", vbInformation, Application.UserName
    TextBox1.Text = "": TextBox2.Text = ""
    TextBox3.Text = "": TextBox4.Text = "": TextBox5.Text = ""
    rs.Close
    evn.Close
    UserForm_Initialize
End Sub
Kod:
Private Sub ListBox1_Click()
    With ListBox1
        TextBox1.Value = .Column(1)
        TextBox2.Value = .Column(2)
        TextBox3.Value = .Column(3)
        TextBox4.Value = .Column(4)
        TextBox5.Value = .Column(5)
        If TextBox5.Value = "" Then
            Set Image1.Picture = Nothing
            'MsgBox "Resim Yok"
        Else
        Image1.Picture = LoadPicture(TextBox5.Text)
        End If
    End With
End Sub
Kod:
Private Sub TextBox1_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    TextBox1.Text = "": TextBox2.Text = ""
    TextBox3.Text = "": TextBox4.Text = "": TextBox5.Text = ""
End Sub
 

Ekli dosyalar

murat bey çok sağolun kayıt sil - arama ve kayıt görüntüleyi de ben tamamlayayım. bu arada bağlanamama sebebim baya bi detaylıymış. acaba access 2007 de yapılmış bir database bağlanabilirmiydim sizce?
 
Rica ederim...
O nedenle hepsini bitirmedim. :)

Access 2007 için connectionstring'i değiştirmeniz gerek.
Şu iki satırı bulup değiştirebilirsiniz;
Kod:
dosya = "C:\ogrenci.accdb"
con.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & dosya
 
şu hoş olmayan mesajımı send edermisiniz ? :S
 
Geri
Üst