Output parameters are not returned when you run an ADO.NET command in Visual C# (308621)
The information in this article applies to:
- Microsoft ADO.Net 2.0
- Microsoft ADO.NET (included with the .NET Framework) 1.0
- Microsoft Visual C# 2005
- Microsoft Visual C# .NET (2003)
- Microsoft Visual C# .NET (2002)
This article was previously published under Q308621 For a Microsoft Visual Basic .NET version of this
article, see
308051. For a Microsoft Visual C++
.NET version of this article, see
308624. This article refers
to the following Microsoft .NET Framework Class Library namespaces:
- System.Data.SqlClient
- System.Data.OleDb
SYMPTOMS Output parameters do not appear to be initialized or return
a wrong value when you run an ADO.NET command. CAUSE This problem can occur for two reasons:
- Output parameters are returned at the end of the data
stream when you use a DataReader object.
- The Direction property of the parameter is set not set properly.
RESOLUTION To resolve this problem, use one of the following methods:
- When you use a DataReader object, you must close it or read to the end of the data before
you can view the output parameters.
- Make sure that the direction of the parameter is set to Output or InputOutput (if the parameter is used in the procedure to both send and
receive data).
For more information about how to implement these solutions,
see the "More Information" section. NOTE: The parameter object for the return value must be the first item
in the Parameters collection. In addition, make sure that the parameter's data type
matches the expected return value. STATUSThis
behavior is by design.REFERENCESFor additional information, click the article number below to
view the article in the Microsoft Knowledge Base: 308049 HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual Basic .NET
Modification Type: | Minor | Last Reviewed: | 10/4/2006 |
---|
Keywords: | kbtshoot kbnofix kbprb kbSqlClient kbStoredProc kbSystemData KB308621 kbAudDeveloper |
---|
|