带有阿拉伯语列名的update语句中的语法错误

时间:2015-05-19 22:59:41

标签: .net vb.net visual-studio-2008

我有一个包含阿拉伯语列名的Access 2007数据库。

我想要做的是使用整数作为主键的图像更新,但是我收到一条错误,说UPDATE语句语法中有错误。

这是相关代码

Private Sub InsertImage(ByRef barcode As Image, ByRef photo As Image, ByVal recID As String)
    Dim conn As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\المشروع\April2015.accdb")
    Dim photodata As MemoryStream = New MemoryStream
    Dim barcodedata As MemoryStream = New MemoryStream
    photo.Save(photodata, ImageFormat.Png)
    barcode.Save(barcodedata, ImageFormat.Png)
    Dim photobytes() As Byte = photodata.GetBuffer()
    Dim barcodebytes() As Byte = barcodedata.GetBuffer()
    Dim query As String = _
    "UPDATE [Records] SET [الصورة] = @photo, SET [باركود] = @barcode WHERE [رقم السجل] = @recID"
    Dim cmd As OleDbCommand = New OleDbCommand(query, conn)
    Dim pParam As OleDbParameter = New OleDbParameter("@photo", OleDbType.Binary)
    pParam.Value = photobytes
    pParam.Size = photobytes.Length
    Dim bParam As OleDbParameter = New OleDbParameter("@barcode", OleDbType.Binary)
    bParam.Value = barcodebytes
    bParam.Size = barcodebytes.Length
    Dim rParam As OleDbParameter = New OleDbParameter("@recID", OleDbType.Integer)
    rParam.Value = Int32.Parse(recID)
    cmd.Parameters.Add(pParam)
    cmd.Parameters.Add(bParam)
    cmd.Parameters.Add(rParam)
    conn.Open()
    cmd.ExecuteNonQuery()
    conn.Close()
End Sub

错误详情为:

System.Data.OleDb.OleDbException was unhandled


ErrorCode=-2147217900
  Message="Syntax error in UPDATE statement."
  Source="Microsoft Office Access Database Engine"
  StackTrace:
       at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
       at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
       at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
       at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
       at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
       at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
       at WindowsApplication1.Entry.InsertImage(Image& barcode, Image& photo, String recID) in E:\المشروع\Records\Records\Entry.vb:line 92
       at WindowsApplication1.Entry.doUpsert() in E:\المشروع\Records\Records\Entry.vb:line 32
       at WindowsApplication1.Entry.SaveButton_Click(Object sender, EventArgs e) in E:\المشروع\Records\Records\Entry.vb:line 41
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at WindowsApplication1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

1 个答案:

答案 0 :(得分:1)

您有多个set子句,而您只需要一个,无论您要更新多少列:

UPDATE [Records] 
SET    [الصورة] = @photo, [باركود] = @barcode 
WHERE  [رقم السجل] = @recID