Buat agan agan mohon pencerahannya buat ane yang lagi mulai belajar vb. ane lagi coba belaar untuk membuat aplikasi pake vb 2010 express dan menggunkan db acces 2007 namun ketemu kendala sintax error ketika menuliskan kode untuk melakukan save data ke
db
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
Dim koneksidb As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\bahrul\Documents\Visual Studio 2010\Projects\dasa\dasa\dbsantri.accdb;Persist Security Info=True")
koneksidb.Open()
MsgBox("Simpan")
Dim perintahdb As New OleDbCommand("select * from santri", koneksidb)
Dim datasantri = perintahdb.ExecuteReader
Dim jumlah As Integer = 1
While datasantri.Read
jumlah += 1
End While
koneksidb.Close()
Try
koneksidb.Open()
Dim perintah2db As New OleDbCommand("insert into santri (Nis,Nama Lengkap,Nama Panggilan,Jenis Kelamin,Tempat lahir,Tanggal Lahir,Anak ke,Jumlah Saudara,Kewarganegaraan,Tingkat sekolah Formal,Alamat,Status,Mulai Masuk,sekolah Asal,Nama Ayah,Nama Ibu,Pkerjaan Ayah,Pekerjaan Ibu,Alamat Wali,Tlp Ayah,Telp Ibu,foto) values('" & jumlah + 1 & "','" & tbnis.Text & "','" & tblengkap.Text & "','" & tbpanggilan.Text & "','" & Combokelamin.Text & "','" & tbanak.Text & "','" & tbsaudara.Text & "','" & tbnegara.Text & "','" & tbkelas.Text & "','" & tbalamat.Text & "','" & Combostatus.Text & "','" & Datemasuk.Text & "','" & tbasal.Text & "','" & tbtempat.Text & "','" & Datelahir.Text & "','" & tbayah.Text & "','" & tbibu.Text & "','" & tbkerja1.Text & "','" & tbkerja2.Text & "','" & tbwali.Text & "','" & tbtelp1.Text & "','" & tbtlp2.Text & "','" & foto.Text & "')", koneksidb)
perintah2db.ExecuteNonQuery()
koneksidb.Close()
MsgBox("sukses")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub