The Size property of the Output parameter is ignored when you use an OLE DB managed provider (318681)



The information in this article applies to:

  • Microsoft ADO.NET (included with the .NET Framework) 1.0
  • Microsoft ADO.NET (included with the .NET Framework 1.1)

This article was previously published under Q318681

SYMPTOMS

If you use an OLE DB managed provider, the OLE DB managed provider ignores the Size property set on an Output parameter if the type of parameter is LongVarChar, LongVarWChar, or LongVarBinary.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to reproduce the behavior

In the following steps to reproduce the behavior, a Microsoft Visual Basic .NET Windows application connects to an Oracle database by using an OLE DB managed provider:
  1. In Oracle SQL*Plus, create the following stored procedure:
    Create or Replace Procedure outparam(param1 out varchar2)
     as
      begin
      param1:='helllllllllllllloooooo';
     end;
    					
  2. Create a new Microsoft Visual Basic .NET Windows Application.
  3. Make sure that your project contains a reference to the System.Data namespace.
  4. Place a Command button on Form1, and then change the button's Name property to btnTest.
  5. Use the Imports statement on the System, System.Data, and System.Data.Oledb namespaces, so that you do not have to qualify declarations in those namespaces later in your code.
    Imports System
    Imports System.Data
    Imports System.Data.Oledb
    					
  6. Paste the following code in the code window after the region "Windows Form Designer generated code":
    Private Sub btnTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest.Click
        Dim myConnString As String = _
            "Provider=MSDAORA;Data Source=myServer;user id=id;password=pwd;Persist Security info=False;"
        Dim cnOra As New OleDbConnection(myConnString)
        Dim cmd1 As New OleDbCommand()
        cmd1.CommandType = CommandType.StoredProcedure
        cmd1.Connection = cnOra
        cmd1.CommandText = "outparam"
        cmd1.Parameters.Add("test", OleDbType.LongVarChar, 2)
        cmd1.Parameters("test").Direction = ParameterDirection.Output
        cnOra.Open()
        cmd1.ExecuteNonQuery()
        MessageBox.Show(cmd1.Parameters("test").Value)
        cnOra.Close()
    End Sub
    					
  7. Modify the Connection string (myConnString) as appropriate for your environment.
  8. Save your project. On the Debug menu, click Start, and then run your project.
  9. Click the button, and you see that the output parameter value that is returned is "helllllllllllllloooooo" instead of "he".

REFERENCES

For more information about connecting to Oracle by using ADO.NET, click the following article number to view the article in the Microsoft Knowledge Base:

308071 How to access an Oracle database using Visual Basic .NET

For more information about ADO.NET, click the following article number to view the article in the Microsoft Knowledge Base:

313590 Roadmap for ADO.NET


Modification Type:MajorLast Reviewed:3/13/2006
Keywords:kbtshoot kbDataAdapter kbManaged kbprb kbSystemData KB318681 kbAudDeveloper