Issue with System.EnterpriseServices trying to connect to Oracle DB - oracle

I used VS2019 on Windows 10 64.
In a .NET Winform application (using .NET v5 framework), I'd like to interact with Oracle DB which is running on a distant server.
So, I installed SQL Developper, Oracle Client in C:\App\db_home. SQL Developper works fine and can access to the Oracle DB perfectly.
I add to my VS Project the reference which seems to be the good one (pretty hesistating on that part but "trying is the way to success") : C:\App\db_home\ODP.NET\bin\4\Oracle.DataAccess.dll
Everything seems ok:
Here's my code to get the connection working (the italic text was edited for posting this online)
Public Function OpenOracleBddConnexion()
Dim Public strOracleConnection As String = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=*Host_URL*)(PORT=*DB_Port*))) (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=*SERVICE_NAME*))); User Id=*USER_ID*;Password=*User_ID*;"
Dim strMsgException As String = "Problème de connexion aux bases Oracles. " & strMsgErrorTellYourAdmin & vbCrLf & "-- Message d'erreur: "
Dim conn As New OracleConnection
Dim cmd As New OracleCommand
Dim adapter As New OracleDataAdapter
Try
conn.ConnectionString = strOracleConnection
conn.Open()
Exit Try
Catch ex As Exception
MsgBox(strMsgException & ex.Message, MsgBoxStyle.Critical, "Erreur Connexion Bases Oracle")
Return Nothing
Exit Try
End Try
End Function
Here is the cryptic error i had:
Could not load file or assembly 'System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Le fichier spécifié est introuvable.

Related

Could not find installable ISAM while opening excel file with OLE driver

I am getting a "Could not find installable ISAM" error in the asp.net webform using visual basic. I am using .Net 4.6 framework. I tried different combinations of connection strings and I also tried with a single quote on Extended Properties as many online solutions suggested but the error did not go away. My code is as below:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim conn As OleDbConnection
Dim dta As OleDbDataAdapter
Dim dts As DataSet
Dim excel As String
excel = "C:\Users\ishfaq.babar\Downloads\aaa.xlsx"
'Dim openfiledialog As New OpenFileDialog
'conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excel + ";Extended Properties='Excel 12.0;'";")
conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\ishfaq.babar\Downloads\aaa.xlsx;Extended Properties='Excel 12.0;HDR=YES;Persist Security Info=False'")
dta = New OleDbDataAdapter("select * from [Sheet1$]", conn)
dts = New DataSet
dta.Fill(dts, "[Sheet1$]")
ExcelGridData.DataSource = dta
ExcelGridData.DataBind()
End Sub
i got error on line
dta.Fill(dts, "[Sheet1$]")
Moreover,I have installed both versions of ole drivers x64 and X86 and I had installed ole driver by command line as:
accessdatabaseengine /quiet
accessdatabaseengine_X64 /quiet
Because I was getting error from GUI Installer as:
microsoft.ace.oledb.12.0' provider is not registered on the local machine
ScreenShot of installed drivers is as follows:
OLE Drivers.Installed Access database Engine versions
ERROR has been resolved automatically with no change in code at all. Just after login again to my account after taking a break it runs successfully:
EDIT:
I Put conn.Open() after connection string.
New Code is As Below:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim conn As OleDbConnection
Try
Dim dta As OleDbDataAdapter
Dim dts As DataSet
Dim excel As String
excel = "C:\Users\ishfaq.babar\Downloads\aaa.xlsx"
'Dim openfiledialog As New OpenFileDialog
'conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excel + ";Extended Properties='Excel 12.0;'";")
conn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\ishfaq.babar\Downloads\aaa.xlsx;Extended Properties='Excel 12.0;HDR=YES;Persist Security Info=False'")
conn.Open()
'PrintLine('ok')
' conn.Close()
dta = New OleDbDataAdapter("select * from [Sheet1$]", conn)
dts = New DataSet
dta.Fill(dts, "[Sheet1$]")
ExcelGridData.DataSource = dta
ExcelGridData.DataBind()
Catch ex As Exception
conn.Close()
End Try
End Sub
Read data successfully from excel file as below screenshot:
Result of data read from excel file

Oracle client very slow to timeout after switching to Windows 10 (and changing provider in connection string)

I'm currently porting a legacy VB6 application to Windows 10. It connects to an Oracle database (currently running Oracle 11g on the client). In order for this to work I had to update the provider in the connection string from "MSDAORA" to "ORAOLEDB.Oracle".
For the most part this works fine, but if I give the string a Data Source that doesn't exist (Which several of the tests do), then it takes a LONG time for it to time out and return an appropriate error message (e.g. ORA-12154 TNS could not resolve the connect identifier). This isn't just down to changing the provider as I can make the same change on Windows 7, and the timeout is a more reasonable 60 seconds or so.
Where can I configure these settings? The sqlnet.ora file is the same in both Win7 and Win10.
Here's a simple example of how I connect to the database:
Private Function OpenConn(databaseName As String) As ADODB.Connection
Const cstrPROC As String = "OpenConn"
On Error GoTo ErrorHandle
#If TRACE And 1 Then
Call OutputDebugString(cstrPROC & vbNewLine)
#End If
Dim conDB As ADODB.Connection
Set conDB = New ADODB.Connection
With conDB
'.CursorLocation = adUseClient
Call .Errors.Clear
Call .Open(Provider=ORAOLEDB.Oracle;Data Source=" & databaseName, "USERNAME", "PASSWORD")
End With
Set OpenConn = conDB
Exit Function
ErrorHandle:
Call Err.Raise(Err.Number, , Err.Description)
End Function

VB6 application ado connection for TLS1.2

I have to support a VB6 application that is still in production (ugh). A customer is specifying our software needs to be PCI compliant which requires TLS 1.2.
Anyone know how to do this?
I am using SQL Server 2014. I'm patched to build 12.0.4502.0.
Public Function GetConnection() As ADODB.Connection
Dim con As ADODB.Connection
On Error Resume Next
Set con = New ADODB.Connection
con.ConnectionTimeout = 10
Dim connstring As String
'connstring = "Provider=SQLOLEDB;Server=" & gstrServer & ";Database=" & gstrDB & ";User Id=" & gstrUser & ";Password=" & gstrPwd
connstring = "Provider=MSDASQL;DRIVER=Sql Server;Server=" & gstrServer & ";Database=" & gstrDB & ";UID=" & gstrUser & ";PWD=" & gstrPwd
con.Open connstring
If Err Then Set con = Nothing
Set GetConnection = con
End Function
The project is referencing "Microsoft ADO Ext. 6.0 for DDL and Security" and "Microsoft ActiveX Data Objects 2.5 Library"
I have tried multiple connection string options.
Thanks!
I found the answer in Using ADO with SQL Server Native Client.
To enable the usage of SQL Server Native Client, ADO applications will
need to implement the following keywords in their connection strings:
Provider=SQLNCLI11
DataTypeCompatibility=80
The following is an example of establishing an ADO connection string that is fully enabled to work
with SQL Server Native Client, including the enabling of the MARS
feature:
Dim con As New ADODB.Connection
con.ConnectionString = "Provider=SQLNCLI11;" _
& "Server=(local);" _
& "Database=AdventureWorks;" _
& "Integrated Security=SSPI;" _
& "DataTypeCompatibility=80;" _
& "MARS Connection=True;"
con.Open
Changing the provider to SQLNCLI11 and adding DataTypeCompatibility=80 worked.

VS 2013 preview - sqlConnection.Open() crashing

This code works perfectly in VS 2010 and 2012.
Dim cmdText As String = "select * from master.dbo.sysdatabases where name=N'" & database & "'"
Dim bRet As Boolean = False
Using sqlConnection As SqlConnection = New SqlConnection(connString)
Try
sqlConnection.Open()
Using sqlCmd As SqlCommand = New SqlCommand(cmdText, sqlConnection)
Using reader As SqlDataReader = sqlCmd.ExecuteReader
bRet = reader.FieldCount > 1
reader.Close()
End Using
End Using
Catch ex As SqlException
MsgBox("Error Trying to Connect to database " & database & vbNewLine & ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
sqlConnection.Close()
End Try
End Using
But when I run it in 2013 this is the error I get at the sqlConnection.Open() command: -
An unhandled exception of type 'System.ExecutionEngineException'
occurred in System.Transactions.dll
If there is a handler for this exception, the program may be safely
continued.
I have found and tried http://connect.microsoft.com/VisualStudio/feedback/details/791339/fatalexecutionengineerror
But to no avail
Has anyone any pointers?
I am stuck.

ADO "Unspecified Error" instead of actual error when fetching server side cursor

This relates to my recent question: Force Oracle error on fetch
I am now able to reproduce a scenario where using ADO with the Oracle OLEDB Provider, I can force an error such as ORA-01722: invalid number to occur on calling Recordset.MoveNext However, this is not the error that is returned to the application. Instead, the application sees Provider error '80004005' Unspecified error. How can I get the application to see the real error from the database? This is with Oracle 10g (client and server), if it matters.
Sample code is roughly as follows:
Dim con As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As ADODB.Recordset
con.ConnectionString = "Provider=OraOLEDB.ORACLE;Data Source=xxx;User Id=yyy;Password=zzz"
con.CursorLocation = adUseServer
con.Open
Set cmd.ActiveConnection = con
cmd.CommandText = "select * from table(ret_err)"
cmd.Prepared = True
Set rs = cmd.Execute
While Not rs.EOF
rs.MoveNext
Wend
SQLCODE and SQLERRM should be returned with an SQL call.
It looks like ADO Error is the interface for accessing this.

Resources