keep getting this error no matter what i do :
Syntax error in INSERT INTO statement.
using the exact same piece of code in other forms and it's working fine..anyone help me solve this please? it's 5:20 am and this school project is driving me insane
Syntax error in INSERT INTO statement.
using the exact same piece of code in other forms and it's working fine..anyone help me solve this please? it's 5:20 am and this school project is driving me insane
VB.NET:
Public Class CreateProduct
Dim con As New OleDb.OleDbConnection
Dim dbProvider As String
Dim dbSource As String
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
Private Sub CreateProduct_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
dbSource = "Data Source = C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\mySystemRemake\SystemDb.mdb"
con.ConnectionString = dbProvider & dbSource
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Select Case MsgBox("Add this Product to Database?", MsgBoxStyle.YesNo, "Add Product")
Case MsgBoxResult.Yes
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or RichTextBox1.Text = "" Then
MsgBox("Please ensure all fields are completed", 0, "Input Error")
Else : con.Open()
sql = "SELECT * FROM ProductTbl"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "ProductEntry")
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim newentry As DataRow
newentry = ds.Tables("ProductEntry").NewRow()
newentry.Item("ProductName") = TextBox1.Text
newentry.Item("Product Information") = RichTextBox1.Text
newentry.Item("Product Quantity") = CInt(TextBox4.Text)
newentry.Item("Product Price") = CInt(TextBox3.Text)
newentry.Item("Type") = TextBox2.Text
ds.Tables("ProductEntry").Rows.Add(newentry)
da.Update(ds, "ProductEntry")
ds.Clear()
MsgBox("Product succesfully added to Database", 0, "")
con.Close()
End If
Case MsgBoxResult.No
Me.Close()
End Select
End Sub
End Class