INSERT INTO命令中的语法错误 [英] Syntax Error in INSERT INTO Command

查看:86
本文介绍了INSERT INTO命令中的语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在进入一个

访问数据库的新行时遇到了一些问题,我想知道的是我有没有

来分配某些我的INSERT INTO SQL语句中的值。

我读过有关命令构建器的信息,它说自动生成了

insert命令。以下是我的

代码。有人可以帮助我进入语法错误

发生的地方:


Dim readwrite As OleDb.OleDbDataAdapter

Dim CmdBuilder As OleDb.OleDbCommandBuilder

Dim ds As DataSet = New DataSet()

Dim table As DataTable

Dim row As DataRow


''sqlstring是全局变量,带字符串"选择

*来自inv_compt_invest"

readwrite =新OleDb.OleDbDataAdapter(sqlstring,

dbInventaire)

CmdBuilder =新OleDb.OleDbCommandBuilder

(readwrite)

readwrite.InsertCommand =

CmdBuilder.GetInsertCommand()

MsgBox(readwrite.InsertCommand.CommandText)

尝试

readwrite.Fill(ds," inv_compt_invest")


''来自数据集的输出数据

table = ds.Tables.Item(0)

如果table.Rows.Count <> 0然后


''输入新记录

如果newdataentry = True那么

row = table.NewRow()

row(" Date d''acquisition")= CDate

(TextBox2.Text)

row(" Num de Compte")= CInt

(TextBox3.Text)

row(" Designation de l''article")=

TextBox4.Text

row(" Quantite)= CInt(TextBox5.Text)

row(" Fournisseur")= TextBox6.Text

row(" Num de la facture)=

TextBox7.Text

row(" Marque")= TextBox8.Text

row(" Localization") = TextBox9.Text

table.Rows.Add(row)


''更新数据库表

readwrite.Update

(ds," inv_compt_invest")''异常被触发

这里通过调试

newdataentry = False

Else

MsgBox(需要输入新数据才能保存

到数据库")

结束如果

结束如果

Catch ex As Exception

MsgBox(ex.Message )

结束尝试


谢谢,


Sam

解决方案

你连接的数据库是什么?另外,为什么要调用这行代码

readwrite.InsertCommand = CmdBuilder.GetInsertCommand()?

-

Carsten Thomsen


使用VS .NET,UML和MSF进行企业开发
http://www.apress.com/book/bookDisplay.html?bID=105

" Samy K" < SK ****** @ hotmail.com>在消息中写道

news:34 **************************** @ phx.gbl ... < blockquote class =post_quotes>我在进入
访问数据库的新行时遇到了一些问题,我想知道的是我有什么要在我的INSERT中分配某些值INTO SQL语句。
我已阅读有关命令构建器的信息,它说自动生成了
insert命令。以下是我的代码。有人可以帮我解决语法错误发生的地方:

Dim readwrite As OleDb.OleDbDataAdapter
Dim CmdBuilder As OleDb.OleDbCommandBuilder
Dim ds As DataSet =新的DataSet()
Dim table As DataTable
Dim row As DataRow

''sqlstring是带字符串的全局变量" Select inv /> * from inv_compt_invest"
readwrite = New OleDb.OleDbDataAdapter(sqlstring,
dbInventaire)
CmdBuilder =新OleDb.OleDbCommandBuilder
(readwrite)
readwrite.InsertCommand =
CmdBuilder.GetInsertCommand()
MsgBox(readwrite.InsertCommand.CommandText)
尝试
readwrite.Fill(ds,inv_compt_invest)

''从数据集输出数据
table = ds.Tables.Item(0)
如果table.Rows.Count<> 0然后

''输入新记录
如果newdataentry = True则
row = table.NewRow()
row(" Date d''acquisition") = CDate
(TextBox2.Text)
row(&num de Compte")= CInt
(TextBox3.Text)
row(" Designation de l''article" )=
TextBox4.Text
row(" Quantite")= CInt(TextBox5.Text)
row(" Fournisseur")= TextBox6.Text
row(" row) Num de la facture")=
TextBox7.Text
row(" Marque")= TextBox8.Text
row(" Localization")= TextBox9.Text
表。 Rows.Add(行)

''更新数据库表
readwrite.Update
(ds," inv_compt_invest")''异常被触发
这里通过调试
newdataentry = False
另外
MsgBox(需要输入新数据来保存数据库)
结束如果
结束如果
Catch ex Exception
MsgBox(ex.Message)
结束尝试

谢谢,

Sam



你好,


Samy K < SK ****** @ hotmail.com> schrieb:

我在进入
访问数据库的新行时遇到了一些问题,而我想知道的是我是否已经分配了某些值在我的INSERT INTO SQL语句中。
我已阅读有关命令构建器的信息,它说自动生成了
insert命令。以下是我的代码。有人可以帮我解决语法错误发生的地方:




这是一个VB.NET语言组。请转到ADO.NET新闻组:

news://msnews.microsoft.com/microsof...amework.adonet

网页界面:

http://msdn.microsoft.com/newsgroups...amework.adonet


-

Herfried K. Wagner

MVP·VB Classic,VB .NET
http://www.mvps.org/dotnet




我正在连接到访问数据库在我的

计算机本地。我正在使用CommandBuilder,因为我读了

,它提供了一种机制来自动生成

命令,用于促进在

OleDbDataSet中进行的更新到相应的表。如果你给我

一些关于问题发生的地方以及为什么会发生这种情况会发生什么。不幸的是,我已经告诉他们这不是正确的发布组。我的

电子邮件回复是 sk******@hotmail.com


谢谢


Samy

-----原始消息-----
什么数据库你在连接吗?另外,为什么
调用这行codereadwrite.InsertCommand = CmdBuilder.GetInsertCommand()?

-
Carsten Thomsen

企业发展与VS .NET,UML和MSF
http: //www.apress.com/book/bookDisplay.html?bID=105
Samy K < SK ****** @ hotmail.com>在消息中写道
新闻:34 **************************** @ phx.gbl ...

我在进入
访问数据库的新行时遇到了一些问题,而我想知道的是我需要在我的INSERT INTO SQL $ b中分配某些值$ b声明。我已经阅读了关于命令构建器的信息,它说
自动生成insert命令。以下是我的代码。有人可以帮助我进入语法
错误发生的地方:

Dim readwrite As OleDb.OleDbDataAdapter
Dim CmdBuilder As OleDb.OleDbCommandBuilder
Dim ds As DataSet =新的DataSet()
Dim table As DataTable
Dim row As DataRow

''sqlstring是全局变量,带有
string" Select * from inv_compt_invest"
readwrite = New OleDb.OleDbDataAdapter
(sqlstring,dbInventaire)
CmdBuilder =新OleDb.OleDbCommandBuilder
(readwrite)
readwrite.InsertCommand =
CmdBuilder.GetInsertCommand()
MsgBox(readwrite.InsertCommand.CommandText)
尝试
readwrite.Fill(ds,inv_compt_invest)

''从数据集输出数据
table = ds.Tables.Item(0)
如果table.Rows.Count<> 0然后

''输入新记录
如果newdataentry = True则
row = table.NewRow()
row(" Date d''acquisition") = CDate
(TextBox2.Text)
row(&num de Compte")= CInt
(TextBox3.Text)
row(" Designation de l''article" )=
TextBox4.Text
row(" Quantite")= CInt
(TextBox5.Text)行(" Fournisseur")= TextBox6.Text
row(" Num de la facture")=
TextBox7.Text
row(" Marque")= TextBox8.Text
row(" Localization")= TextBox9.Text
表。 Rows.Add(行)

''更新数据库表
readwrite.Update
(ds," inv_compt_invest")''异常被触发
这里通过调试
newdataentry = False
其他
MsgBox(需要输入新数据到
保存到数据库)
结束如果
结束如果
Catch ex Exception
MsgBox(ex.Message)
结束尝试

谢谢,

Sam





I''m having a bit of problems entering a new row to an
access database and what I would like to know is do I have
to assign certain values in my INSERT INTO SQL statement.
I have read about the commandbuilder and it said that the
insert command is automatically generated. Below is my
code. Can someone help me out into where the syntax error
is happening:

Dim readwrite As OleDb.OleDbDataAdapter
Dim CmdBuilder As OleDb.OleDbCommandBuilder
Dim ds As DataSet = New DataSet()
Dim table As DataTable
Dim row As DataRow

''sqlstring is global variable with string "Select
* from inv_compt_invest"
readwrite = New OleDb.OleDbDataAdapter(sqlstring,
dbInventaire)
CmdBuilder = New OleDb.OleDbCommandBuilder
(readwrite)
readwrite.InsertCommand =
CmdBuilder.GetInsertCommand()
MsgBox(readwrite.InsertCommand.CommandText)
Try
readwrite.Fill(ds, "inv_compt_invest")

''output data from dataset
table = ds.Tables.Item(0)
If table.Rows.Count <> 0 Then

''Enter new records
If newdataentry = True Then
row = table.NewRow()
row("Date d''acquisition") = CDate
(TextBox2.Text)
row("Num de Compte") = CInt
(TextBox3.Text)
row("Designation de l''article") =
TextBox4.Text
row("Quantite") = CInt(TextBox5.Text)
row("Fournisseur") = TextBox6.Text
row("Num de la facture") =
TextBox7.Text
row("Marque") = TextBox8.Text
row("Localisation") = TextBox9.Text
table.Rows.Add(row)

''Update the database table
readwrite.Update
(ds, "inv_compt_invest") ''The exception gets triggered
here through debugging
newdataentry = False
Else
MsgBox("Need to enter new data to save
to Database")
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try

thanks,

Sam

解决方案

What database are you connecting to? Also, why do you call this line of code
readwrite.InsertCommand = CmdBuilder.GetInsertCommand()?
--
Carsten Thomsen

Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
"Samy K" <sk******@hotmail.com> wrote in message
news:34****************************@phx.gbl...

I''m having a bit of problems entering a new row to an
access database and what I would like to know is do I have
to assign certain values in my INSERT INTO SQL statement.
I have read about the commandbuilder and it said that the
insert command is automatically generated. Below is my
code. Can someone help me out into where the syntax error
is happening:

Dim readwrite As OleDb.OleDbDataAdapter
Dim CmdBuilder As OleDb.OleDbCommandBuilder
Dim ds As DataSet = New DataSet()
Dim table As DataTable
Dim row As DataRow

''sqlstring is global variable with string "Select
* from inv_compt_invest"
readwrite = New OleDb.OleDbDataAdapter(sqlstring,
dbInventaire)
CmdBuilder = New OleDb.OleDbCommandBuilder
(readwrite)
readwrite.InsertCommand =
CmdBuilder.GetInsertCommand()
MsgBox(readwrite.InsertCommand.CommandText)
Try
readwrite.Fill(ds, "inv_compt_invest")

''output data from dataset
table = ds.Tables.Item(0)
If table.Rows.Count <> 0 Then

''Enter new records
If newdataentry = True Then
row = table.NewRow()
row("Date d''acquisition") = CDate
(TextBox2.Text)
row("Num de Compte") = CInt
(TextBox3.Text)
row("Designation de l''article") =
TextBox4.Text
row("Quantite") = CInt(TextBox5.Text)
row("Fournisseur") = TextBox6.Text
row("Num de la facture") =
TextBox7.Text
row("Marque") = TextBox8.Text
row("Localisation") = TextBox9.Text
table.Rows.Add(row)

''Update the database table
readwrite.Update
(ds, "inv_compt_invest") ''The exception gets triggered
here through debugging
newdataentry = False
Else
MsgBox("Need to enter new data to save
to Database")
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try

thanks,

Sam



Hello,

"Samy K" <sk******@hotmail.com> schrieb:

I''m having a bit of problems entering a new row to an
access database and what I would like to know is do I have
to assign certain values in my INSERT INTO SQL statement.
I have read about the commandbuilder and it said that the
insert command is automatically generated. Below is my
code. Can someone help me out into where the syntax error
is happening:



This is a VB.NET language group. Please turn to the ADO.NET newsgroup:

news://msnews.microsoft.com/microsof...amework.adonet

Web interface:

http://msdn.microsoft.com/newsgroups...amework.adonet

--
Herfried K. Wagner
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet



I''m connecting to an access database locally on my
computer. I am using the CommandBuilder because I read
that it provides a mechanism to automatically generate
commands used to facilitate the updates made in an
OleDbDataSet to the corresponding table. If you give me
some points as to where the problem is occuring and why
it occurs that would be appreciated. Unfortunately I''ve
been told that this is not the right group to post. My
email to reply is sk******@hotmail.com

thanks

Samy

-----Original Message-----
What database are you connecting to? Also, why do you call this line of codereadwrite.InsertCommand = CmdBuilder.GetInsertCommand()?
--
Carsten Thomsen

Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
"Samy K" <sk******@hotmail.com> wrote in message
news:34****************************@phx.gbl...

I''m having a bit of problems entering a new row to an
access database and what I would like to know is do I have to assign certain values in my INSERT INTO SQL statement. I have read about the commandbuilder and it said that the insert command is automatically generated. Below is my
code. Can someone help me out into where the syntax error is happening:

Dim readwrite As OleDb.OleDbDataAdapter
Dim CmdBuilder As OleDb.OleDbCommandBuilder
Dim ds As DataSet = New DataSet()
Dim table As DataTable
Dim row As DataRow

''sqlstring is global variable with string "Select * from inv_compt_invest"
readwrite = New OleDb.OleDbDataAdapter (sqlstring, dbInventaire)
CmdBuilder = New OleDb.OleDbCommandBuilder
(readwrite)
readwrite.InsertCommand =
CmdBuilder.GetInsertCommand()
MsgBox(readwrite.InsertCommand.CommandText)
Try
readwrite.Fill(ds, "inv_compt_invest")

''output data from dataset
table = ds.Tables.Item(0)
If table.Rows.Count <> 0 Then

''Enter new records
If newdataentry = True Then
row = table.NewRow()
row("Date d''acquisition") = CDate
(TextBox2.Text)
row("Num de Compte") = CInt
(TextBox3.Text)
row("Designation de l''article") =
TextBox4.Text
row("Quantite") = CInt (TextBox5.Text) row("Fournisseur") = TextBox6.Text
row("Num de la facture") =
TextBox7.Text
row("Marque") = TextBox8.Text
row("Localisation") = TextBox9.Text
table.Rows.Add(row)

''Update the database table
readwrite.Update
(ds, "inv_compt_invest") ''The exception gets triggered
here through debugging
newdataentry = False
Else
MsgBox("Need to enter new data to save to Database")
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try

thanks,

Sam


.



这篇关于INSERT INTO命令中的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆