I have made a data connection and some custom code in Visual Basic for Applications to search for data in a SQL database:
Dim myAdoQueryConnection As AdoQueryConnection = Me.DataConnections("brKlientTabel2")
Dim myNav1 As XPathNavigator = CreateNavigator().SelectSingleNode("/my:myFields/my:CL_OwnersShareholders", NamespaceManager)
Dim owners As String = myNav1.InnerXml
myAdoQueryConnection.Command = "SELECT * FROM brKlientTabel WHERE '%" & owners & "%'"
This gives an error message:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
if I select using this line:
myAdoQueryConnection.Command = "SELECT * FROM brKlientTabel WHERE '" & owners & "%'"
it works.
There seems to be a problem searching with a percent sign at the very start of the search string, could this be the case, or am I doing something else wrong?
Best regards,
Tomas Rudh
Sweden