Here is my code :
the program stops at da.Update(ds, "Vita") it says Syntax error in UPDATE statement.
the program stops at da.Update(ds, "Vita") it says Syntax error in UPDATE statement.
VB.NET:
Imports System.Data.OleDb
Public Class Form2
Dim con As New OleDb.OleDbConnection
Dim inc As Integer
Dim MaxRows As Integer
Dim dbProvider As String
Dim dbSource As String
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
Private Sub VitaBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
Me.Validate()
Me.VitaBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.VitaPlus_1DataSet)
End Sub
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'ProductsDataSet.Soup_etc' table. You can move, or remove it, as needed.
Me.Soup_etcTableAdapter.Fill(Me.ProductsDataSet.Soup_etc)
'TODO: This line of code loads data into the 'ProductsDataSet.Beauty_Products' table. You can move, or remove it, as needed.
Me.Beauty_ProductsTableAdapter.Fill(Me.ProductsDataSet.Beauty_Products)
'TODO: This line of code loads data into the 'ProductsDataSet.Beauty_Products' table. You can move, or remove it, as needed.
Me.Beauty_ProductsTableAdapter.Fill(Me.ProductsDataSet.Beauty_Products)
'TODO: This line of code loads data into the 'ProductsDataSet.Products' table. You can move, or remove it, as needed.
Me.ProductsTableAdapter.Fill(Me.ProductsDataSet.Products)
'TODO: This line of code loads data into the 'VitaPlus_1DataSet.Vita' table. You can move, or remove it, as needed.
Me.VitaTableAdapter.Fill(Me.VitaPlus_1DataSet.Vita)
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
dbSource = "Data Source = C:\Users\pirate\Documents\Visual Studio 2012\Projects\FirstVitaPlusI\VitaPlus 1.mdb"
con.ConnectionString = dbProvider & dbSource
con.Open()
sql = " SELECT *FROM Vita"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "Vita")
MsgBox("Database is now open")
con.Close()
MsgBox("Database is now Closed")
Dim vita As New DataTable
'ito ung code sa isa
GroupBox4.Visible = True
MaxRows = ds.Tables("Vita").Rows.Count
inc = -1
showitems()
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Me.VitaBindingSource.Filter = "First_Name= '" & Me.TextBox1.Text & "'"
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs)
Form3.Show()
End Sub
Private Sub Button6_Click_1(sender As Object, e As EventArgs) Handles Button6.Click
My.Computer.Audio.Play(My.Resources.Windows_User_Account_Control, AudioPlayMode.WaitToComplete)
Form3.Show()
End Sub
Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.CheckedChanged
If RadioButton1.Checked = True Then
DataGridView1.Visible = True
Beauty_ProductsDataGridView.Visible = False
Soup_etcDataGridView.Visible = False
End If
End Sub
Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton2.CheckedChanged
If RadioButton2.Checked = True Then
DataGridView1.Visible = False
Beauty_ProductsDataGridView.Visible = True
Soup_etcDataGridView.Visible = False
End If
End Sub
Private Sub RadioButton3_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton3.CheckedChanged
If RadioButton3.Checked = True Then
DataGridView1.Visible = False
Beauty_ProductsDataGridView.Visible = False
Soup_etcDataGridView.Visible = True
End If
End Sub
Private Sub webBrowser_NewWindow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles WebBrowser1.NewWindow
e.Cancel = True
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs)
My.Computer.Audio.Play(My.Resources.Windows_User_Account_Control, AudioPlayMode.WaitToComplete)
Me.Hide()
Form4.Show()
End Sub
Private Sub ToolStripButton14_Click(sender As Object, e As EventArgs) Handles ToolStripButton14.Click
Me.Validate()
Me.VitaBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.VitaPlus_1DataSet)
End Sub
Private Sub mnuExit_Click(sender As Object, e As EventArgs) Handles mnuExit.Click
Me.Close()
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
Try
TextBox2.Text = TextBox2.Text
Soup_etcDataGridView.DataSource = Me.ProductsDataSet.Soup_etc.Select("Product like'" & TextBox2.Text & "'")
Catch ex As System.Data.StrongTypingException
Finally
End Try
End Sub
Private Sub RadioButton4_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton4.CheckedChanged
My.Computer.Audio.Play(My.Resources.Windows_User_Account_Control, AudioPlayMode.WaitToComplete)
GroupBox1.Visible = True
GroupBox2.Visible = False
GroupBox3.Visible = False
GroupBox4.Visible = True
GroupBox6.Visible = False
End Sub
Private Sub RadioButton5_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton5.CheckedChanged
My.Computer.Audio.Play(My.Resources.Windows_User_Account_Control, AudioPlayMode.WaitToComplete)
GroupBox1.Visible = False
GroupBox2.Visible = True
DataGridView1.Visible = True
GroupBox3.Visible = False
GroupBox4.Visible = False
GroupBox6.Visible = False
Me.Dealers_NumberTextBox.ReadOnly = True
Me.Nick_NameTextBox.ReadOnly = True
Me.Last_NameTextBox.ReadOnly = True
Me.First_NameTextBox.ReadOnly = True
Me.Middle_NameTextBox.ReadOnly = True
Me.NationalityTextBox.ReadOnly = True
Me.AdressTextBox.ReadOnly = True
Me.Civi_StatusTextBox.ReadOnly = True
Me.SexTextBox.ReadOnly = True
Me.NotesTextBox.ReadOnly = True
Me.Cellular_Phone_NumberTextBox.ReadOnly = True
Me.Telephone_NumberTextBox.ReadOnly = True
Me.E_mail_addressTextBox.ReadOnly = True
End Sub
Private Sub RadioButton6_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton6.CheckedChanged
My.Computer.Audio.Play(My.Resources.Windows_User_Account_Control, AudioPlayMode.WaitToComplete)
WebBrowser1.Navigate("http://firstvitaplus.net/index.html")
GroupBox1.Visible = False
GroupBox2.Visible = False
GroupBox3.Visible = True
GroupBox4.Visible = False
GroupBox6.Visible = False
Me.Dealers_NumberTextBox.ReadOnly = True
Me.Nick_NameTextBox.ReadOnly = True
Me.Last_NameTextBox.ReadOnly = True
Me.First_NameTextBox.ReadOnly = True
Me.Middle_NameTextBox.ReadOnly = True
Me.NationalityTextBox.ReadOnly = True
Me.AdressTextBox.ReadOnly = True
Me.Civi_StatusTextBox.ReadOnly = True
Me.SexTextBox.ReadOnly = True
Me.NotesTextBox.ReadOnly = True
Me.Cellular_Phone_NumberTextBox.ReadOnly = True
Me.Telephone_NumberTextBox.ReadOnly = True
Me.E_mail_addressTextBox.ReadOnly = True
End Sub
Private Sub RadioButton8_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton8.CheckedChanged
My.Computer.Audio.Play(My.Resources.Windows_User_Account_Control, AudioPlayMode.WaitToComplete)
Me.Hide()
Form4.Show()
End Sub
Private Sub RadioButton9_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton9.CheckedChanged
GroupBox6.Show()
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
dbSource = "Data Source = C:\Users\pirate\Documents\Visual Studio 2012\Projects\FirstVitaPlusI\VitaPlus 1.mdb"
con.ConnectionString = dbProvider & dbSource
con.Open()
sql = " SELECT *FROM Vita"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "Vita")
MsgBox("Database is now open")
con.Close()
MsgBox("Database is now Closed")
Dim vita As New DataTable
End Sub
Private Sub showitems()
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter
con.Open()
da = New OleDbDataAdapter("Select * from vita", con)
da.Fill(dt)
con.Close()
End Sub
Private Sub NavigateRecords()
TextBox3.Text = ds.Tables("Vita").Rows(inc).Item(0)
TextBox4.Text = ds.Tables("Vita").Rows(inc).Item(1)
TextBox5.Text = ds.Tables("Vita").Rows(inc).Item(2)
TextBox6.Text = ds.Tables("Vita").Rows(inc).Item(3)
TextBox7.Text = ds.Tables("Vita").Rows(inc).Item(4)
TextBox8.Text = ds.Tables("Vita").Rows(inc).Item(5)
TextBox9.Text = ds.Tables("Vita").Rows(inc).Item(6)
TextBox10.Text = ds.Tables("Vita").Rows(inc).Item(7)
TextBox11.Text = ds.Tables("Vita").Rows(inc).Item(8)
TextBox12.Text = ds.Tables("Vita").Rows(inc).Item(9)
TextBox13.Text = ds.Tables("Vita").Rows(inc).Item(10)
TextBox14.Text = ds.Tables("Vita").Rows(inc).Item(11)
End Sub
Private Sub GroupBox6_Enter(sender As Object, e As EventArgs) Handles GroupBox6.Enter
MaxRows = ds.Tables("Vita").Rows.Count
inc = -1
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
If inc <> MaxRows - 1 Then
inc = inc + 1
NavigateRecords()
Else
MsgBox("No More Rows")
End If
End Sub
Private Sub Button2_Click_1(sender As Object, e As EventArgs) Handles Button2.Click
If inc > 0 Then
inc = inc - 1
NavigateRecords()
Else
MsgBox("First Record")
End If
End Sub
Private Sub Button3_Click_1(sender As Object, e As EventArgs) Handles Button3.Click
If inc <> MaxRows - 1 Then
inc = MaxRows - 1
NavigateRecords()
Else
MsgBox("You're already in the last record")
End If
End Sub
Private Sub Button4_Click_1(sender As Object, e As EventArgs) Handles Button4.Click
If inc <> 0 Then
inc = 0
NavigateRecords()
Else
MsgBox("You're already in te fires record")
End If
End Sub
Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("Vita").Rows(inc).Item(0) = TextBox3.Text
ds.Tables("Vita").Rows(inc).Item(1) = TextBox4.Text
ds.Tables("Vita").Rows(inc).Item(2) = TextBox3.Text
ds.Tables("Vita").Rows(inc).Item(3) = TextBox4.Text
ds.Tables("Vita").Rows(inc).Item(4) = TextBox3.Text
ds.Tables("Vita").Rows(inc).Item(5) = TextBox4.Text
ds.Tables("Vita").Rows(inc).Item(6) = TextBox3.Text
ds.Tables("Vita").Rows(inc).Item(7) = TextBox4.Text
ds.Tables("Vita").Rows(inc).Item(8) = TextBox3.Text
ds.Tables("Vita").Rows(inc).Item(9) = TextBox4.Text
ds.Tables("Vita").Rows(inc).Item(10) = TextBox3.Text
'ds.Tables("Vita").Rows(inc).Item(11) = TextBox4.Text
ds.Tables("Vita").Rows(inc).Item(12) = TextBox4.Text
da.Update(ds, "Vita")>>>>>>>>the program stops here....it says Syntax error in UPDATE statement.
MsgBox("Data updated"):err:
End Sub
End Class
Last edited by a moderator: