FIX: The .NET Framework Managed Provider for OLE DB may not return an Oracle error message if the locale setting is not "en-us"

Article translations Article translations
Article ID: 326722 - View products that this article applies to.
This article was previously published under Q326722
This article has been archived. It is offered "as is" and will no longer be updated.
Expand all | Collapse all

On This Page

Summary

In a Microsoft ADO.NET application that uses the Microsoft .NET Managed Provider for OLE DB together with the Microsoft OLE DB Provider for Oracle, if the locale setting for your application is anything other than en-us, the .NET Managed Provider for OLE DB may not return any Oracle error messages that may occur. To resolve the problem, download and install a hotfix. To obtain the hotfix, contact Microsoft Product Support Services.

Symptoms

You can use the Microsoft .NET Managed Provider for OLE DB together with the Microsoft OLE DB Provider for Oracle in your Microsoft ADO.NET application. However, if the locale setting for your application is anything other than en-us, the .NET Framework Managed Provider for OLE DB may not return any Oracle error messages that may occur.

Resolution

A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that this article describes. Apply it only to systems that are experiencing this specific problem.

To resolve this problem, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:
http://support.microsoft.com/contactus/?ws=support
Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question. The P1 version of this P2 has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
 
   Date         Time   Version            Size    File name
   --------------------------------------------------------------

   22-Jul-2002  18:43  1.0.3705.298    1,175,552  System.data.dll

Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

More information

Steps to reproduce the behavior

Create an ASP.NET Web Application project

  1. Start Visual Studio .NET.
  2. On the File menu, point to New, and then click Project.
  3. Under Project Types, click Visual Basic Projects, and then click ASP.NET Web Application under Templates.
  4. Click OK. By default, the WebForm1.aspx Web form is created.
  5. In Solution Explorer, right-click WebForm1.aspx, and then click View Code.
  6. Replace the existing code in the WebForm1.aspx.vb file with the following code.

    Notes
    • The following code retrieves the parameters for the various connection strings from the configuration file for your application. To make sure that this code works as expected, you must store the values for these parameters in the configuration file for your application.
    • In the following code, modify the connection strings for your environment.
    • In the following code, modify the CommandText objects to contain queries that involve a non-existent table.
    Imports System.Data.OracleClient
    Imports Microsoft.Data.Odbc
    Imports System.Data.OleDb
    Imports System.Threading
    Imports System.Globalization
    
    Public Class WebForm1
       Inherits System.Web.UI.Page
       Protected WithEvents Button1 As System.Web.UI.WebControls.Button
       Protected WithEvents Button2 As System.Web.UI.WebControls.Button
       Protected WithEvents Button3 As System.Web.UI.WebControls.Button
       Protected WithEvents Button4 As System.Web.UI.WebControls.Button
    
       Public m_strLocale As String
    
    #Region " Web Form Designer Generated Code "
    
       'This call is required by the Web Form Designer.
       <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    
       End Sub
    
       Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
          'CODEGEN: This method call is required by the Web Form Designer.
          'Do not modify it using the code editor.
          InitializeComponent()
       End Sub
    
    #End Region
    
       Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
          'Put user code to initialize the page here.
          m_strLocale = GetLocale()
          SetLocale()
       End Sub
    
       Private Sub GetDBConnValues(ByRef strUser As String, ByRef strPassword As String, ByRef strDataSource As String)
          Try
             Dim objConfig As ConfigurationSettings
    
             strUser = ConfigurationSettings.AppSettings("User")
             strPassword = ConfigurationSettings.AppSettings("Password")
             strDataSource = ConfigurationSettings.AppSettings("DataSource")
          Catch ex As Exception
             Response.Write(" Message " & ex.Message)
          End Try
       End Sub
    
       Private Function GetLocale() As String
          Dim oCookie As HttpCookie
          oCookie = Page.Request.Cookies("Locale")
    
          If Not oCookie Is Nothing AndAlso Not oCookie.Value Is Nothing Then
             Return oCookie.Value
          Else
             Return "en-us"
          End If
       End Function
    
       Private Sub SetLocale()
          Thread.CurrentThread.CurrentUICulture = New CultureInfo(m_strLocale)
          Thread.CurrentThread.CurrentCulture = New CultureInfo(m_strLocale)
          Response.Write("The locale setting is " & m_strLocale)
       End Sub
    
       Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
          Dim oCookie As HttpCookie
    
          If m_strLocale = "en-us" Then
             m_strLocale = "fr-fr"
          Else
             m_strLocale = "en-us"
          End If
    
          oCookie = New HttpCookie("Locale", m_strLocale)
          Response.Cookies.Set(oCookie)
          SetLocale()
       End Sub
    
       Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
          Dim objConn As New OracleConnection()
          Dim objCmd As New OracleCommand()
          Dim strUser, strPass, strSource As String
    
          GetDBConnValues(strUser, strPass, strSource)
    
          Try
             objConn = New OracleConnection("Data Source=" & strSource & ";User ID=" & strUser & _
                                            ";Password=" & strPass)
             objConn.Open()
    
             If objConn.State = ConnectionState.Open Then
                objCmd = New OracleCommand()
                objCmd.CommandType = CommandType.Text
                objCmd.CommandText = "select nothing from mytable"
                objCmd.Connection = objConn
                objCmd.ExecuteReader()
                objConn.Close()
             End If
          Catch ex As OracleException
             Response.Write(" Message " & ex.Message)
             Response.Write(" Error Code " & ex.Code.ToString())
    
             If objConn.State = ConnectionState.Open Then
                objConn.Close()
             End If
          End Try
       End Sub
    
       Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
          Dim objConn As OdbcConnection
          Dim objCmd As OdbcCommand
          Dim strUser, strPass, strSource As String
    
          GetDBConnValues(strUser, strPass, strSource)
    
          Try
             objConn = New OdbcConnection("Driver={Microsoft ODBC for Oracle};Server=server;User ID=" & strUser & _
                                            ";Password=" & strPass)
             objConn.Open()
    
             If objConn.State = ConnectionState.Open Then
                objCmd = New OdbcCommand()
                objCmd.CommandType = CommandType.Text
                objCmd.CommandText = "select nothing from mytable"
                objCmd.Connection = objConn
                objCmd.ExecuteReader()
                objConn.Close()
             End If
          Catch ex As OdbcException
             Response.Write(" Message " & ex.Message)
             Response.Write(" Native Error " & ex.Errors.Item(0).NativeError.ToString())
             Response.Write(" SqlState " & ex.Errors.Item(0).SQLState.ToString())
    
             If objConn.State = ConnectionState.Open Then
                objConn.Close()
             End If
          End Try
       End Sub
    
       Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
          Dim objConn As OleDbConnection
          Dim objCmd As OleDbCommand
          Dim strUser, strPass, strSource As String
    
          GetDBConnValues(strUser, strPass, strSource)
    
          Try
             objConn = New OleDbConnection("Provider=MSDAORA.1;Data Source=" & strSource & ";User ID=" & strUser & _
                                            ";Password=" & strPass)
             objConn.Open()
    
             If objConn.State = ConnectionState.Open Then
                objCmd = New OleDb.OleDbCommand()
                objCmd.CommandType = CommandType.Text
                objCmd.CommandText = "select nothing from mytable"
                objCmd.Connection = objConn
                objCmd.ExecuteReader()
                objConn.Close()
             End If
          Catch ex As OleDbException
             Response.Write(" Message " & ex.Message)
             Response.Write(" Error Code " & ex.ErrorCode.ToString())
    
             Response.Write(" Native Error " & ex.Errors.Item(0).NativeError.ToString())
             Response.Write(" SqlState " & ex.Errors.Item(0).SQLState.ToString())
    
             If objConn.State = ConnectionState.Open Then
                objConn.Close()
             End If
          End Try
       End Sub
    
    End Class

Add HTML controls to the Web form

  1. Switch to Design view of the WebForm1.aspx Web form.
  2. On the View menu, click HTML Source.
  3. Replace the existing HTML source code for the WebForm1.aspx Web form with the following HTML code:
    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="WebApplication1.WebForm1"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
       <HEAD>
          <title>WebForm1</title>
          <meta name="GENERATOR" content="Microsoft Visual Studio. NET 7.0">
          <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
          <meta name="vs_defaultClientScript" content="JavaScript">
          <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
       </HEAD>
       <body MS_POSITIONING="GridLayout">
          <form id="Form1" method="post" runat="server">
             <P>
                <asp:Button id="Button1" runat="server" Text="Change Locale"></asp:Button>
                <asp:Button id="Button2" runat="server" Text="Use the .NET Framework Managed Provider for Oracle"></asp:Button>
                <asp:Button id="Button3" runat="server" Text="Use the .NET Framework Managed Provider for ODBC together with the ODBC Driver for Oracle"></asp:Button>
                <asp:Button id="Button4" runat="server" Text="Use the .NET Framework Managed Provider for OLE DB together with the OLE DB Driver for Oracle"></asp:Button>
             </P>
          </form>
       </body>
    </HTML>

Add references to the project

  1. In Solution Explorer, right-click the References node, and then click Add Reference. The Add Reference dialog box appears.
  2. Under Component Name on the .NET tab, click System.Data.OracleClient, and then click Select.
  3. Under Component Name, click Microsoft.Data.Odbc.
  4. Click Select, and then click OK.
Downloads


The following files are available for download from the Microsoft Download Center:
Collapse this imageExpand this image
Download
Download the .NET Framework Managed Provider for Oracle package now.
Collapse this imageExpand this image
Download
Download the ODBC .NET Data Provider package now. For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591 How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

Build and run the ASP.NET Web application

  1. On the Build menu, click Build Solution.
  2. On the Debug menu, click Start. The WebForm1 Web form opens in your Web browser.
  3. Click Change Locale.
  4. Click Use the .NET Framework Managed Provider for Oracle, and notice the text that appears on the WebForm1 Web form.
  5. Click Use the .NET Framework Managed Provider for ODBC together with the ODBC Driver for Oracle, and notice the text that appears on the WebForm1 Web form.
  6. Click Use the .NET Framework Managed Provider for OLE DB together with the OLE DB Driver for Oracle, and notice the text that appears on the WebForm1 Web form.
You notice that when you use the .NET Framework Managed Provider for Oracle or the .NET Framework Managed Provider for ODBC together with the ODBC Driver for Oracle, these providers return the Oracle error message that occurs. However, when you use the .NET Framework Managed Provider for OLE DB together with the OLE DB Driver for Oracle, this provider may not return the Oracle error message that occurs.

References

For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
824684 Description of the standard terminology that is used to describe Microsoft software updates
For more information, visit the following Microsoft Developer Network (MSDN) Web sites:
Accessing data with ADO.NET
http://msdn2.microsoft.com/en-us/library/e80y5yhx(vs.71).aspx
.NET Framework data providers
http://msdn2.microsoft.com/en-us/library/a6cd7c08(vs.71).aspx
Using .NET Framework data providers to access data
http://msdn.microsoft.com/en-us/library/s7ee2dwt.aspx

Properties

Article ID: 326722 - Last Review: October 26, 2013 - Revision: 2.0
Applies to
  • Microsoft Visual Studio .NET 2002 Professional Edition
  • Microsoft Visual Studio .NET 2002 Enterprise Architect
  • Microsoft Visual Studio .NET 2002 Enterprise Developer
  • Microsoft Visual Studio .NET 2002 Academic Edition
Keywords: 
kbnosurvey kbarchive kbhotfixserver kbqfe kbprovider kbmanaged kblocalization kboracle kbfix KB326722

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com