更新语句的语法错误 [英] Syntax Error on Update Statement
问题描述
我的更新语句出现语法错误。我正在使用Visual Basic 2008.请帮助我,因为我需要尽快完成。提前感谢那些发表评论的人..
<前lang =vb> 进口 System.Data
Imports System.Data.OleDb
公共 类 ControlFile
Dim cnnOLEDB As 新 OleDbConnection
Dim cmdOLEDB 作为 新 OleDbCommand
Dim cmdInsert 作为 新 OleDbCommand
Dim cmdUpdate 作为 新 OleDbCommand
< span class =code-keyword> Dim cmdRemove 作为 新 OleDbCommand
Dim strConnectionString = Provider = Microsoft.ACE.OLEDB.12.0; Data Source = E:\VB Programs\AIS.accdb
私有 Sub ControlFile_Load( ByVal 发件人作为系统。对象, ByVal e As System.EventArgs)句柄 MyBase .Load
cnnOLEDB.ConnectionString = strConnectionString
cnnOLEDB.Open()
结束 Sub
私有 Sub cmdEdit_Click( ByVal sender As System。 Object , ByVal e As System.EventArgs)句柄 cmdEdit.Click
如果 OrganizationTextBox.Text<> 和 CalendarYearTextBox.Text< > 然后
cmdUpdate.CommandText = UPDATE ControlFile SET& _
Organization ='& OrganizationTextBox.Text& ',& _
CalendarYear ='& CalendarYearTextBox.Text& ',& _
EarningsControl ='& EarningsControlTextBox.Text& ',& _
EarningsAccount ='& EarningsAccountTextBox.Text& ',& _
RetainedControl ='& RetainedControlTextBox.Text& ',& _
RetainedAccount ='& RetainedAccountTextBox.Text& ',& _
DebitCredit ='& DebitCreditTextBox.Text& ',& _
CurrentPeriod ='& CurrentPeriodTextBox.Text& ',& _
WHERE Organization ='& OrganizationTextBox.Text& '
您的上一个更新列CurrentPeriod最后不应该有逗号。
您的上一个更新项目与之间不存在逗号WHERE子句。
逗号存在于where条件之前所以只有它才会显示erro请删除那个
CurrentPeriod ='& CurrentPeriodTextBox。 Text & '& _
WHERE Organization ='& OrganizationTextBox。文字&
I got syntax error on my update statement. I am using Visual Basic 2008. Please do help me for I need to finish this asap. Thanks in advance for those who will give their comments..
Imports System.Data
Imports System.Data.OleDb
Public Class ControlFile
Dim cnnOLEDB As New OleDbConnection
Dim cmdOLEDB As New OleDbCommand
Dim cmdInsert As New OleDbCommand
Dim cmdUpdate As New OleDbCommand
Dim cmdRemove As New OleDbCommand
Dim strConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= E:\VB Programs\AIS.accdb"
Private Sub ControlFile_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cnnOLEDB.ConnectionString = strConnectionString
cnnOLEDB.Open()
End Sub
Private Sub cmdEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEdit.Click
If OrganizationTextBox.Text <> "" And CalendarYearTextBox.Text <> "" Then
cmdUpdate.CommandText = "UPDATE ControlFile SET " & _
"Organization = '" & OrganizationTextBox.Text & "', " & _
"CalendarYear = '" & CalendarYearTextBox.Text & "', " & _
"EarningsControl = '" & EarningsControlTextBox.Text & "', " & _
"EarningsAccount = '" & EarningsAccountTextBox.Text & "', " & _
"RetainedControl = '" & RetainedControlTextBox.Text & "', " & _
"RetainedAccount = '" & RetainedAccountTextBox.Text & "', " & _
"DebitCredit = '" & DebitCreditTextBox.Text & "', " & _
"CurrentPeriod = '" & CurrentPeriodTextBox.Text & "', " & _
"WHERE Organization = '" & OrganizationTextBox.Text & "'"
Your last updating column, CurrentPeriod, shouldn't have a comma at the end.
No comma should exist in between your last update item and the WHERE clause.
Comma exists before the where condition so only it will show erro please remove that one
"CurrentPeriod = '" & CurrentPeriodTextBox.Text & "' " & _ "WHERE Organization = '" & OrganizationTextBox.Text & "'"
这篇关于更新语句的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!