Hello
Basically I want to to be able to insert things into my textboxes on vb.net and for them to go into my microsoft access file and into the customers table when I click the save button. I tried doing it myself I didn't succeed my work kept on erroring with this:[imgnothumb]http://i56.tinypic.com/ilxaok.jpg[/imgnothumb]
Heres my code:
Now my database is called: Kit-tactic.accdb
The fields I hold are: forename, surname, dob, housenumber, address 1, address 2, postcode, contact
Thanks for any help :)
Basically I want to to be able to insert things into my textboxes on vb.net and for them to go into my microsoft access file and into the customers table when I click the save button. I tried doing it myself I didn't succeed my work kept on erroring with this:[imgnothumb]http://i56.tinypic.com/ilxaok.jpg[/imgnothumb]
Heres my code:
Code:
Public Class frmCustomers Private OleDbInsertCommand1 As System.Data.OleDb.OleDbCommand Private OleDbConnection1 As System.Data.OleDb.OleDbConnection Private OleDbDataAdapter1 As System.Data.OleDb.OleDbDataAdapter Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click OleDbInsertCommand1 = New System.Data.OleDb.OleDbCommand OleDbConnection1 = New System.Data.OleDb.OleDbConnection OleDbInsertCommand1.CommandText = "INSERT INTO [Customer] (forename, surname, dob, housenumber, address 1, address 2, postcode, contact) VALUES ('" & txtForename.Text & "', '" & txtSurname.Text & "', '" & txtHousenumber.Text & "', '" & txtAddress1.Text & "', '" & txtAddress2.Text & "', '" & txtPostcode.Text & "', '" & txtContact.Text & "')" OleDbInsertCommand1.Connection = Me.OleDbConnection1 OleDbConnection1.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; " _ & "Data Source=E:\Ian Griffiths\Kit-tactic.accdb" Try OleDbConnection1.Open() OleDbInsertCommand1.ExecuteNonQuery() Catch ex As OleDb.OleDbException MessageBox.Show(ex.ToString) End Try OleDbConnection1.Close() End Sub End Class
The fields I hold are: forename, surname, dob, housenumber, address 1, address 2, postcode, contact
Thanks for any help :)
Comment