[QODBC ALL] sp_batchupdate Throws AccessViolationException When SELECT Runs Before Batch Commands
Problem Description:
When using QODBC batch procedures (sp_batchstart, sp_batchclear, sp_batchupdate) in a .NET/C# application, executing any SELECT query before calling sp_batchstart causes the subsequent sp_batchupdate to throw a System.AccessViolationException:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Affected products: QODBC Desktop, .NET applications using ODBC connection strings Expected outcome: A SELECT query before batch procedures should not interfere with batch operations. Batch updates should work regardless of prior SELECT statements on the same connection.
Symptoms:
- A .NET/C# application using a QODBC ODBC connection executes a normal
SELECT query.
- Subsequently calling
sp_batchstart, inserting/updating records, and then sp_batchupdate throws System.AccessViolationException.
- Removing the preceding
SELECT statement makes the batch operation work correctly.
- The issue only occurs when a SELECT result set is left open or not fully consumed before beginning a batch sequence on the same connection.
Cause:
This is a known bug in QODBC Desktop (tracked as B01770). The QODBC driver's ODBC cursor state is not fully reset after a SELECT result set, which corrupts the connection state before batch operations begin.
Bug Reference
This issue is tracked as B01770 on the QODBC internal bug list. The issue has been fixed and released in QODBC version 361.
Environment:
| Product | Version / Detail |
| QODBC Desktop |
All versions affected |
| .NET Framework |
C# / VB.NET with System.Data.Odbc |
Workaround:
Do not execute any SELECT queries on the same ODBC connection before batch operations. If your application needs data from a SELECT query before running batch commands, use a separate ODBC connection for the SELECT operation.
- Create two ODBC connections: Use one connection exclusively for data reads (SELECT queries) and another for batch write operations.
- Close any result sets fully before starting a batch sequence on the same connection.
- Reopen the connection before running sp_batchstart if a SELECT was used on it previously.
Keywords:
B01770 AccessViolationException sp_batchupdate Batch Operations C# .NET ODBC Connection Protected Memory
Support Tickets: DLT-531-13344
|