Saturday, February 25, 2012

AccessViolationException from SQLDataSource

I'n getting a randomAccessViolationException during the select operation of an SqlDataSource (ASP.NET 2.x), after I have modified the CommandText from it'sSelecting event.

I know it's considered a bad idea to dynamically modify the SQL rather than use parameters, but in this instance, I'm more concerned as to why this exception is occurring. It *only* happens if I modify the CommandText and even then I'd say it only occurs 10% of the time. More annoying than anything is that it is returning the correct results. I can catch the exception from theSelected event and the stack trace reveals that the failing method isSQLExecDirectW.

There is nothing wrong with the CommandText syntax and MS documentation states that it can be changed from the Selecting event, so I'm at odds as to why this is happening.

For completeness, the reason I can't use parameters is that I'm using the ODBC Datasource with a Paradox database (Intersolv drivers). I need an optional predicate and IsNull() is not supported, and I cannot get the {fn IFNULL(?, Table.`Field`)} escape sequence to work with an SQL input parameter.

Can anyone put me out of my misery?

This is an exception throwned from unmanaged code because something is trying to access protected memory so it sounds like the database drivers.

Have you checked for updated drivers ? You should probably report the bug to the people providing these drivers.

No comments:

Post a Comment