Problems with updating SAP table using WCF LOB Adapter -
01-23-2009
, 02:41 AM
Hi,
Within SAP the table "TableName" resides which I query with select and
update SQL statements using the .NET Provider\SAP Data Provider which is part
of the WCF LOB Adapter.
Select statement: SELECT ColumnNameB FROM TableName WHERE ColumnNameA =
'MyValue'
Update statement: UPDATE TableName SET ColumnNameB = 'MyData' WHERE
ColumnNameA = 'MyValue'
I tried to execute those SQL statements using an Execute SQL Task and a
Script Component. The selection of data works perfect, but updating data
raises an error (the administrator gave me full privileges to the table):
Error: Executing the query "UPDATE TableName SET ColumnNameB = 'MyData'
WHERE ColumnNameA = 'MyValue'" failed with the following error: "Syntax error
in the specified query. Specify a valid query.". Possible failure reasons:
Problems with the query, "ResultSet" property not set correctly, parameters
not set correctly, or connection not established correctly.
Selecting data works...
Public Overrides Sub CreateNewOutputRows()
Dim sapCmd As IDbCommand
Dim sapRdr As IDataReader
Dim sapConnection As IDbConnection
Dim affectedRows As Int32
Try
sapConnection =
CType(Connections.Connection.AcquireConnection(Not hing), IDbConnection)
sapCmd = sapConnection.CreateCommand()
sapCmd.CommandText = "SELECT ColumnNameB FROM TableName WHERE
ColumnNameA = 'MyValue'"
sapCmd.Prepare()
sapRdr = sapCmd.ExecuteReader()
While (sapRdr.Read())
OutputRowsBuffer.AddRow()
OutputRowsBuffer.Value = sapRdr.GetString(1)
End While
Catch ex As Exception
OutputRowsBuffer.AddRow()
OutputRowsBuffer.Value = ex.StackTrace.ToString()
End Try
End Sub
....but updating data fails.
Public Overrides Sub CreateNewOutputRows()
Dim sapCmd As IDbCommand
Dim sapRdr As IDataReader
Dim sapConnection As IDbConnection
Dim affectedRows As Int32
Try
sapConnection =
CType(Connections.Connection.AcquireConnection(Not hing), IDbConnection)
sapCmd = sapConnection.CreateCommand()
sapCmd.CommandText = "UPDATE TableName SET ColumnNameB = 'MyData'
WHERE ColumnName = 'MyValue'"
sapCmd.Prepare()
affectedRows = sapCmd.ExecuteNonQuery()
OutputRowsBuffer.AddRow()
OutputRowsBuffer.Value = affectedRows.ToString()
Catch ex As Exception
OutputRowsBuffer.AddRow()
OutputRowsBuffer.Value = ex.StackTrace.ToString()
End Try
End Sub
Has anyone experienced this problem before? How can I solve this problem?
Thank you in advance!
Regards,
Johan Machielse |