I use QTP/UFT for my application testing. I had to access my oracle DB (11g) to do some DB setup (to update records).
I use oracle.manageddataaccess.dll
(referenced to myDBWrapper class library project).
I have below dlls
(myDBWrapper is the one I created - where the issue is present)
My connection string:
Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=<HOST>)(PORT=<PORT>>)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=<SERVICENAME>)));User Id=<USERNAME>;Password=<PASSWORD>;
Issue:
The below code during conn.open()
throws error. It works sometimes & sometimes throws an error that 'Object reference not to set an instance of an object' in the same machine.
conn = New OracleConnection()
conn.ConnectionString = ConnectionString
MsgBox("isnothing? : " & (conn Is Nothing).ToString) 'it is always False. So , not null
conn.Open() ' It throws an error that "Object reference not to set an instance of an object"
Dim cmd As OracleCommand = New OracleCommand(strQuery)
cmd.BindByName = True
cmd.Connection = conn
RowsAffected = cmd.ExecuteNonQuery()
cmd.Dispose()
conn.Dispose()
Note:
It is not a resource leak. I just make 1 connection and dispose. No one else is connecting to the DB.
Issue happens - When QTP has COM lib. When i use that to automate & make it invisible (QTP.Visible = FALSE
). If I use QTP.Visible = TRUE - issue does not happen. What kind of issue is this!!!
StackTrace :
Object reference not set to an instance of an object.
at OracleInternal.I18N.Conv.GetMaxBytesPerChar(Int32 charsetId)
at OracleInternal.ServiceObjects.OracleConnectionImpl.Connect(ConnectionString cs, Boolean bOpenEndUserSession)
at OracleInternal.ConnectionPool.PoolManager`3.CreateNewPR(Int32 reqCount, Boolean bForPoolPopulation, ConnectionString csWithDiffOrNewPwd)
at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd)
at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword)
at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword)
at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
at myDBWrapper.Utility.DBUtil.OpenConnection()
driver.vbs
which uses QTP's AOM - it should hide QTP during the startup. Once QTP is invoked, it starts executing all the actions. There is a global object initialized using dotnetfactory with the dll by QTP once QTP is invoked. If i have to make it un-hide again, i need a separate function in QTP to do this as driver.vbs can not handle this as it is a separate process. For the time being i am not using hidden mode due to this issue. But I would like to use hidden mode to improve the overall performance. Thanks for checking. – Republicanism