Why does this tell me
Syntax error statement in INSERT
I've searched for more information but it tells me.
This is the code:
import System.Data Imports System.Data.OleDb Public Class F9 Dim ds new datasets dim Da OleDb.OleDbDataAdapter dim con New OleDb.OleDbConnection dim dbProvider string dim dbSource string dim SQL as string (ByVal sender system as as as as as private sub f9_Load. as the object, System E-Agent AvenueRg) MyBase.Load dbProvider = "Provider = Microsoft.Jet.OLEDB.4.0;" DbSource = "Data Source = E: \ 21.MDB" con.ConnectionString = dbProvider & amp; dbSource con.Open () Select SQL = "* breakfast" da = new OleDb.OleDbDataAdapter (SQL, con) da.Fill (DS, "breakfast") da = new OleDb.OleDbDataAdapter (SQL, con) End sub Private sub Button2_Click (ByVal as the System.Object, as ByVal e System.EventArgs) handles b1.Click Me.Close () x = x + (5 * 1) If d.tc.Text = f7. B1.Text again, as the new CBDD, OleDb.OleDbCommandBuilder (DA) dims dsNewRow as DataRow dsNewRow = ds.Tables ("breakfast"). NewRow () dsNewRow.Item ("Date") = f1.d1.Text dsNewRow.Item ("Order") = D. tc.Text dsNewRow.Item (number of "items") = b1.Text dsNewRow.Item ( "Value") = "5" dsNewRow.Item ( "total") = x ds.Tables ( "breakfast"). Rows. Add (DSNERRO) Dr. Update (DS, "Snack") Con. Close and End Sub Sub Clauses
s your omnibox access sql ( date
, order
) and you have field names with spaces in it's default configuration of commandbiller will not produce valid SQL statement in such cases.
To fix this issue, immediately after the line ...
dim CB New OleDb.OleDbCommandBuilder (DA )
... as the addition of the following two rows:
cb.QuotePrefix = "[ "Cb.QuoteSuffix ="] "
This command builder has the square and area name in square brackets ( []
) therefore
Insert into snacks (date, order, number of items) One sent like values Instead of making it ...
This will generate a statement such as The SQL statement requires square brackets that are syntactically correct. INSERT [ Date], [order], [items with numbers]) value ...
Comments
Post a Comment