语法错误插入 [英] syntax error insert into
本文介绍了语法错误插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Imports System.Data.OleDb
Public Class Form1
Dim cn As New OleDbConnection
Dim da As New OleDbDataAdapter("Select * From Stockgn", cn)
Dim da2 As New OleDbDataAdapter("Select * From Stockgn", cn)
Dim ds As New DataSet
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
P1.Height() = Me.Height()
Sgbt.Hide()
Ebt.Hide()
Sbt.Hide()
Cbt.Hide()
Fbt.Hide()
Crbt.Hide()
P2.Width() = Me.Width() - P1.Width()
P2.Height() = Me.Height()
P2.Hide()
P3.Width() = Me.Width() - P1.Width()
P3.Height() = Me.Height()
P3.Hide()
DataGrid2.Width() = Me.Width() - P1.Width() - 100
GBox3.Width() = Me.Width() - P1.Width() - 100
GBox3.Height() = Me.Height() - 200
cn.ConnectionString = "Provider=Microsoft.ACE.Oledb.12.0; data source=Stockgn.accdb"
cn.Open()
da.Fill(ds, "Stockgn")
da.SelectCommand.CommandText = "Select * From Entrée"
da.Fill(ds, "Entrée")
DataGrid2.DataSource = ds.Tables(0)
DGV1.DataSource = ds.Tables(1)
cn.Close()
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim sw As Integer
sw = 0
For s = 0 To Me.DGV1.RowCount - 2
If TextBox7.Text = Me.DGV1.Item(0, s).Value Then
sw = 1
End If
Next
If sw = 0 Then
If TextBox1.Text <> "" And TextBox2.Text <> "" And TextBox3.Text <> "" And TextBox4.Text <> "" And TextBox5.Text <> "" And TextBox6.Text <> "" And TextBox7.Text <> "" Then
Dim NewLigne As DataRow
NewLigne = ds.Tables("Entrée").NewRow
NewLigne(0) = TextBox7.Text
NewLigne(1) = TextBox1.Text
NewLigne(2) = TextBox5.Text
NewLigne(3) = TextBox4.Text
NewLigne(4) = TextBox3.Text
NewLigne(5) = TextBox6.Text
NewLigne(6) = TextBox2.Text
ds.Tables("Entrée").Rows.Add(NewLigne)
Dim cb As New OleDb.OleDbCommandBuilder(da)
da.Update(ds, "Entrée")
Dim CmdBuild As OleDb.OleDbCommandBuilder
CmdBuild = New OleDb.OleDbCommandBuilder(da)
da.InsertCommand = CmdBuild.GetInsertCommand
MsgBox("Ajout Avec Succes", MsgBoxStyle.Information)
cn.Close()
Else
MsgBox("Vous Devez Remplir Touse Les Champs SVP", MsgBoxStyle.Exclamation)
End If
Else
MsgBox("Référence Existe Déjaé", MsgBoxStyle.Critical)
End If
End Sub
我得到 da.Update中的错误(ds,Entrée)
I get an error in the da.Update(ds,"Entrée")
syntax error, insert into
请帮助
please help
推荐答案
您需要修复INSERT语句中的语法错误。由于您尚未发布insert语句,因此我们无法为您缩小范围。
You need to fix the syntax error in your INSERT statement. Since you haven't posted the insert statement we can't narrow it down for you.
要解决此问题,请立即行...
Dim cb As New OleDb.OleDbCommandBuilder(da)
...添加以下两行:
cb.QuotePrefix =[
cb.QuoteSuffix =]
To fix this issue, immediately after the line...
Dim cb As New OleDb.OleDbCommandBuilder(da)
...add the following two lines:
cb.QuotePrefix = "["
cb.QuoteSuffix = "]"
这篇关于语法错误插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文