Microsoft KB Archive/326722

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

Article ID: 326722

Article Last Modified on 5/13/2007

-

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

-



This article was previously published under Q326722





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 &quot;Applies to&quot; section.



Create an ASP.NET Web Application project
 Start Visual Studio .NET. On the File menu, point to New, and then click Project. Under Project Types, click Visual Basic Projects, and then click ASP.NET Web Application under Templates. Click OK. By default, the WebForm1.aspx Web form is created.</li> In Solution Explorer, right-click WebForm1.aspx, and then click View Code.</li>  Replace the existing code in the WebForm1.aspx.vb file with the following code.

Notes <ul> 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.</li> In the following code, modify the connection strings for your environment.</li> In the following code, modify the CommandText objects to contain queries that involve a non-existent table.</li></ul>

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


 * 1) Region &quot; Web Form Designer Generated Code &quot;

'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


 * 1) 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(&quot;User&quot;) strPassword = ConfigurationSettings.AppSettings(&quot;Password&quot;) strDataSource = ConfigurationSettings.AppSettings(&quot;DataSource&quot;) Catch ex As Exception Response.Write(&quot; Message &quot; & ex.Message) End Try End Sub

Private Function GetLocale As String Dim oCookie As HttpCookie oCookie = Page.Request.Cookies(&quot;Locale&quot;)

If Not oCookie Is Nothing AndAlso Not oCookie.Value Is Nothing Then Return oCookie.Value Else Return &quot;en-us&quot; End If  End Function

Private Sub SetLocale Thread.CurrentThread.CurrentUICulture = New CultureInfo(m_strLocale) Thread.CurrentThread.CurrentCulture = New CultureInfo(m_strLocale) Response.Write(&quot;The locale setting is &quot; & 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 = &quot;en-us&quot; Then m_strLocale = &quot;fr-fr&quot; Else m_strLocale = &quot;en-us&quot; End If

oCookie = New HttpCookie(&quot;Locale&quot;, 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(&quot;Data Source=&quot; & strSource & &quot;;User ID=&quot; & strUser & _                                       &quot;;Password=&quot; & strPass) objConn.Open

If objConn.State = ConnectionState.Open Then objCmd = New OracleCommand objCmd.CommandType = CommandType.Text objCmd.CommandText = &quot;select nothing from mytable&quot; objCmd.Connection = objConn objCmd.ExecuteReader objConn.Close End If     Catch ex As OracleException Response.Write(&quot; Message &quot; & ex.Message) Response.Write(&quot; Error Code &quot; & 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(&quot;Driver={Microsoft ODBC for Oracle};Server=server;User ID=&quot; & strUser & _                                       &quot;;Password=&quot; & strPass) objConn.Open

If objConn.State = ConnectionState.Open Then objCmd = New OdbcCommand objCmd.CommandType = CommandType.Text objCmd.CommandText = &quot;select nothing from mytable&quot; objCmd.Connection = objConn objCmd.ExecuteReader objConn.Close End If     Catch ex As OdbcException Response.Write(&quot; Message &quot; & ex.Message) Response.Write(&quot; Native Error &quot; & ex.Errors.Item(0).NativeError.ToString) Response.Write(&quot; SqlState &quot; & 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(&quot;Provider=MSDAORA.1;Data Source=&quot; & strSource & &quot;;User ID=&quot; & strUser & _                                       &quot;;Password=&quot; & strPass) objConn.Open

If objConn.State = ConnectionState.Open Then objCmd = New OleDb.OleDbCommand objCmd.CommandType = CommandType.Text objCmd.CommandText = &quot;select nothing from mytable&quot; objCmd.Connection = objConn objCmd.ExecuteReader objConn.Close End If     Catch ex As OleDbException Response.Write(&quot; Message &quot; & ex.Message) Response.Write(&quot; Error Code &quot; & ex.ErrorCode.ToString)

Response.Write(&quot; Native Error &quot; & ex.Errors.Item(0).NativeError.ToString) Response.Write(&quot; SqlState &quot; & ex.Errors.Item(0).SQLState.ToString)

If objConn.State = ConnectionState.Open Then objConn.Close End If     End Try End Sub

End Class </li></ol>

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

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:

Download the .NET Framework Managed Provider for Oracle package now.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.

<div class="references_section">