Writing a Memo field to an Access DB with OleDB

A

Alfred Malleier

Hello,

I have big problem on updating an Access Memo field with OleDb. While the
InsertCommand works, then UpdateCommand raises an exception: Syntaxerror in
UPDATE-Statement. I tryed various work arounds (the last 3 days) with and
without the CommandBuilder with allways the same result.

The last attempt was:

Public Function WriteMemoToAccess(ByVal Pars As String) As Boolean
'Parameters is the ColumnName of the Access Memo field
Dim AccessCommand As New OleDb.OleDbCommand("UPDATE DocH SET Parameters=?
WHERE IdNum = 1")

Dim QueryParameter As New OleDb.OleDbParameter("@Parameters", _
OleDb.OleDbType.LongVarWChar, Len(Pars), ParameterDirection.Input,
True, _
Nothing, Nothing, Nothing, DataRowVersion.Current, Pars)

AccessCommand.Parameters.Add(QueryParameter)
AccessCommand.Connection = Me.Connection
Me.Connection.Open()
Try
AccessCommand.ExecuteNonQuery()
WriteMemoToAccess = True
Catch ex As Exception
End Try
Me.Connection.Close()
End Function

Is there a way to do this??

Best regards

Alfred Malleier
(South Tyrol)
 
J

Jim Hughes

Is the columnname you want to update really called Parameters?

If so, Parameters is probably a reserved word. Try wrapping it in [ ] or
even renaming the column and associated references.
 
A

Alfred Malleier

Jim Hughes said:
Is the columnname you want to update really called Parameters?

If so, Parameters is probably a reserved word. Try wrapping it in [ ] or
even renaming the column and associated references.

Yes, Parameters is a keyword in OleDb. I found this 10 min ago.
But I find no work around in programm code. I need to change the name in the
Access db

Thank you very much.

Alfred M.
 
P

Paul Clement

¤ > Is the columnname you want to update really called Parameters?
¤ >
¤ > If so, Parameters is probably a reserved word. Try wrapping it in [ ] or
¤ > even renaming the column and associated references.
¤
¤ Yes, Parameters is a keyword in OleDb. I found this 10 min ago.
¤ But I find no work around in programm code. I need to change the name in the
¤ Access db
¤

As Jim mentioned you can enclose it within brackets: [Parameters]


Paul
~~~~
Microsoft MVP (Visual Basic)
 
A

Alfred Malleier

Paul Clement said:
On Tue, 22 Aug 2006 17:20:34 +0200, "Alfred Malleier"


¤ > Is the columnname you want to update really called Parameters?
¤ >
¤ > If so, Parameters is probably a reserved word. Try wrapping it in [ ]
or
¤ > even renaming the column and associated references.
¤
¤ Yes, Parameters is a keyword in OleDb. I found this 10 min ago.
¤ But I find no work around in programm code. I need to change the name in
the
¤ Access db
¤

As Jim mentioned you can enclose it within brackets: [Parameters]


Paul
~~~~
Microsoft MVP (Visual Basic)

Many Thanks,

but if I enclose them in the SelectCommand why the CommandBuilder does not
enclose them in the other commands too?

Alfred M.
 
P

Paul Clement

¤ > ¤ > Is the columnname you want to update really called Parameters?
¤ > ¤ >
¤ > ¤ > If so, Parameters is probably a reserved word. Try wrapping it in [ ]
¤ > or
¤ > ¤ > even renaming the column and associated references.
¤ > ¤
¤ > ¤ Yes, Parameters is a keyword in OleDb. I found this 10 min ago.
¤ > ¤ But I find no work around in programm code. I need to change the name in
¤ > the
¤ > ¤ Access db
¤ > ¤
¤ >
¤ > As Jim mentioned you can enclose it within brackets: [Parameters]
¤ >
¤ >
¤ > Paul
¤ > ~~~~
¤ > Microsoft MVP (Visual Basic)
¤
¤ Many Thanks,
¤
¤ but if I enclose them in the SelectCommand why the CommandBuilder does not
¤ enclose them in the other commands too?

Because the CommandBuilder was not designed to handle this issue. You have to make the modification
manually.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Top