VB Migration Partner

KNOWLEDGE BASE - ADOLibrary


Previous | Index | Next 

[PRB] Invoking an action stored procedure via a Command object may throw an exception

ADODB provides several options when invoking a stored procedure. More specifically, you can invoke a stored procedure without specifying whether it returns a recordset, as in this example:

	Dim cmd As New Command
	Set cmd.ActiveConnection = myConn
	cmd.CommandType = adCmdStoredProc
	cmd.CommandText = "MyStoredProc"
	cmd.Execute
	

Notice that the Execute method doesn’t specify that the stored procedure does not return a recordset (or that we aren’t interested in any returned recordset).

Unfortunately, this approach can’t be easily reproduced in ADO.NET without a severe performance penalty. In fact, under ADO.NET the calling code must use either the ExecuteReader method when it expects one or more data row, or the ExecuteNonQuery method when the stored procedure doesn’t return any data row. This difference is reflected in the way the ADOLibrary works.

For this reason, starting with version 1.35 all calls to the Command.Execute method in the ADOLibrary must specify the adExecuteNoRecords flag in the options parameter if the stored procedure doesn’t return any data row:

	Dim cmd As New Command
	Set cmd.ActiveConnection = myConn
	cmd.CommandType = adCmdStoredProc
	cmd.CommandText = "MyStoredProc"
	cmd.Execute , , adExecuteNoRecords
	

All the calls to the Execute method without the adExecuteNoRecords flag are internally implemented by means of the ExecuteReader ADO.NET method and therefore throw an exception if the stored procedure doesn’t return any method. It is assumed that the developer working at the migration will notice this spurious error and will fix the VB6 code accordingly.

Notice that specifying the adExecuteNoRecords flag is a good habit even if you aren’t converting using the ADOLibrary, as explained in this KB article.

Previous | Index | Next 




Follow Francesco Balena on VB6 migration’s group on

LinkedIn





Read Microsoft Corp’s official case study of a VB6 conversion using VB Migration Partner.




Code Architects and its partners offers remote and onsite migration services.

More details




Subscribe to our free newsletter for useful VB6 migration tips and techniques.

newsletter



To learn more about your VB6 applications, run VB6 Analyzer on your source code and send us the generated text file. You will receive a detailed report about your VB6 applications and how VB Migration Partner can help you to quickly and effectively migrate it to .NET.

Get free advice



A fully-working, time-limited Trial Edition of VB Migration Partner allows you to test it against your actual code

Get the Trial




The price of VB Migration Partner depends on the size of the VB6 application, the type of license, and other factors

Request a quote




Migrating a VB6 application in 10 easy steps

Comparing VB Migration Partner with Upgrade Wizard

Migration tools: Feature Comparison Table

All whitepapers