Microsoft KB Archive/884437

= Incorrect parameter information is returned when you call the GetParameterInfo method, and the command text is set to an ODBC call escape sequence =

Article ID: 884437

Article Last Modified on 1/10/2007

-

APPLIES TO


 * Microsoft Data Access Components 2.8

-





SYMPTOMS
When you use the GetParameterInfo method, and the command text is set to an Open Database Connectivity (ODBC) call escape sequence to obtain parameter information from a stored procedure, incorrect parameter information is returned. For example, when you set the command text to the following ODBC call escape sequence, the information that is returned is about the first parameter instead of about the last parameter. {call yourStoredProcedure(,,,?)} Note  is a placeholder for one of your stored procedures.

In this example, you are requesting information about the last parameter from the  stored procedure. However, information about the first parameter is returned instead.



CAUSE
This problem occurs because a problem in the Microsoft OLE DB Provider for SQL Server (SQLOLEDB) client causes all the parameter information except for the first parameter to be discarded.



WORKAROUND
To work around this problem, use one of the following methods:  Use the Microsoft SQL Server ODBC driver. When you use the SQL Server ODBC driver, the GetParameterInfo method works as expected.  Use Transact-SQL as the command text. To do this, use the SetCommandText method to set the command text to code that is similar to the following code. exec ?=yourStoredProcedure ,,,,? 



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.



Steps to reproduce the behavior
  Create the following stored procedure. CREATE procedure JDATATYPES1 ( @smi smallint = 2718 OUTPUT, @int integer = 2718 OUTPUT , @tin tinyint  = 218  OUTPUT , @bin bigint   = 2718 OUTPUT , @bit bit      = 1    OUTPUT ) as

select @smi; select @int; select @tin; select @bin; select @bit;

set @smi = 3456 ; set @int = 3456 ; set @tin = 234 ; set @bin = 123456789012345; set @bit = 12    ;

return (125); GO  Start Rowset Viewer.

Note Rowset Viewer is included with the Microsoft Data Access Components (MDAC) 2.8 Software Development Kit (SDK). To download the MDAC 2.8 SDK, visit the following Microsoft Web site:

http://www.microsoft.com/downloads/details.aspx?FamilyID=5067faf8-0db4-429a-b502-de4329c8c850&displaylang=en

</li> Connect to the data source where you created the stored procedure in step 1.</li> In the Command window, type the following ODBC call escape sequence:

{call JDATATYPES1(,,,?)}

</li> On the Command menu, click ICommandText, and then click SetCommandText.</li> On the Command menu, click ICommandPrepare, and then click Prepare.</li> On the Command menu, click ICommandWithParameters, and then click GetParameterInfo.

Note Information about the first parameter is returned.</li> In the Command window, type the following Transact-SQL script:

exec ?=JDATATYPES1 ,,,,?

</li> Repeat steps 5 through 7.

Note Information about the last parameter is returned.</li></ol>

<div class="references_section">