In .NET 4.5 I am trying to execute an OleDBCommand on an access database.
The code I have is
Dim rows As Integer
Dim dbCommand As OleDb.OleDbCommand = New OleDb.OleDbCommand
Dim dbTransaction As OleDb.OleDbTransaction
Call gOleCn.Open()
dbTransaction = gOleCn.BeginTransaction
dbCommand = New OleDb.OleDbCommand("", gOleCn, dbTransaction)
dbCommand.CommandText = "UPDATE Tレイヤ管理 SET レイヤー=0 WHERE 名前 LIKE '水田_*';"
rows = dbCommand.ExecuteNonQuery()
The query executes fine in access itself, but in .NET it never affects any rows.
It works if I change the CommandText to "UPDATE Tレイヤ管理 SET レイヤー=0 WHERE 名前='水田_" & Parameter & "'"
and specify the name exactly using Parameter
, but then I'd have to write a loop, whilst with LIKE
it's all done in one line.
But how can this be made to work?