First of all i don't have
any syntax error before RUN my form after that... When I try to UPDATE the database (access.databese)
and with adding NEW customer but I get "oleDbException was unhandled" and the database isn't UPDATE,
I have also try a code that I design (see below the code) since the save bottom at the toolbar it was empty (as default ) but isn't helps me, I get other similar problem Insert Into has syntax error...... I don't know what to do...
Now I really believe that the problem is that the compiler when open the database (access) it's initialize the first TABLE of NorthWind(MAIN TABLE) so when I call the compiler to open the database open the first table and when I try to UPDATE the table of Customers CANNOT find any Table = Customers and prints out the error... (since the compiler open the NorthWind main table and I am trying to UPDATE the Customer TABLE) So i need
to send the compiler into the correct Position at the database but I don't know how to do.....
I am searching 3 days now and I didn't find any solution in google so PLEASE if you have any ideas let me know as soon as possible because it's imagery I have to presetting the project at the middle of the week below it's the CODE that I have done maybe thats HELPS you....
Thank you in advance!!!
VB Code:
Imports Access = Microsoft.Office.Interop.Access Imports System.Data Imports System.Data.OleDb Public Class Form1 Dim provider As String Dim dataFile As String Dim connString As String Dim myConnection As OleDbConnection = New OleDbConnection Private Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesSaveButton.Click provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source =" dataFile = "C:\Users\USER_NAME\Documents\NorthWind_2007.accdb" connString = provider & dataFile myConnection.ConnectionString = connString myConnection.Open() Dim str As String str = "insert into Items ([ID], [First Name], [Last Name], [Street], [Phone]) values (?, ?, ?, ?, ?)" Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection) Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection) cmd.Parameters.Add(New OleDbParameter("ID", CType(TextBox1.Text, String))) cmd.Parameters.Add(New OleDbParameter("Fist Name", CType(TextBox2.Text, String))) cmd.Parameters.Add(New OleDbParameter("Last Name", CType(TextBox3.Text, String))) cmd.Parameters.Add(New OleDbParameter("Street", CType(TextBox4.Text, String))) cmd.Parameters.Add(New OleDbParameter("Phone", CType(TextBox5.Text, String))) Try cmd.ExecuteNonQuery() Catch ex As Exception MsgBox(ex.Message) End Try TextBox1.Clear() TextBox2.Clear() TextBox3.Clear() TextBox4.Clear() TextBox5.Clear() End Sub End Class




Reply With Quote