Some providers, such as SQL Server, implement a forward-scrolling, read-only (or 'firehose') cursor mode, meaning that they can efficiently retrieve data by keeping a connection open. When working with such providers, the connection could be blocked by another user's transaction. The following examples demonstrate scenarios that result in errors.
dbConn.Open "DSN=SQLForum;UID=sa;PWD=;" 'Example 1
dbConn.BeginTrans
RS.Open "SELECT * FROM Message", dbConn
Set dbCmd.ActiveConnection = dbConn
ActiveConnection
is being set to a connection that is forward-scrolling and in 'firehose' mode. This is the same connection involved in the batch mode. The error from the provider will only appear in the Err
object, and it will return as unspecified. For example, with the ODBC Provider, you will get "Unspecified error".dbConn.Open "DSN=SQLForum;UID=sa;PWD=;" 'Example 2
RS.Open "SELECT * FROM Message", dbConn
dbConn.BeginTrans
Errors
collection from the provider will indicate that it is operating in firehose mode, and can't work in transaction mode. For example, with the ODBC Provider against Microsoft SQL Server, you will get the error "Cannot start transaction while in firehose mode".dbConn.Open "DSN=SQLForum;UID=sa;PWD=;" 'Example 3
RS.Open "SELECT * FROM Message", dbConn
Set dbCmd.ActiveConnection = dbConn
dbConn.BeginTrans
Errors
collection from the provider will indicate that the transaction could not be started. For example, with the ODBC Provider against Microsoft SQL Server, you will get the error "Cannot start transaction because more than one hdbc is in use".