Knowledgebase: Sp_commands & Reports
[QODBC ALL] sp_batchupdate Throws AccessViolationException When SELECT Runs Before Batch Commands
Posted by William - QODBC Support on 22 September 2026 12:31 PM

[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:

ProductVersion / 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.

  1. Create two ODBC connections: Use one connection exclusively for data reads (SELECT queries) and another for batch write operations.
  2. Close any result sets fully before starting a batch sequence on the same connection.
  3. 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
(0 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please complete the captcha below (we use this to prevent automated submissions).