8

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)

enter image description here

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()
KitKarson
  • 5,211
  • 10
  • 51
  • 73
  • Please show a complete stack trace. – OldProgrammer Feb 21 '15 at 22:08
  • @OldProgrammer, thanks for checking. added stacktrace. – KitKarson Feb 22 '15 at 00:00
  • @OldProgrammer,As an additional info, QTP is an automation tool. it can import .net dll and use its methods. In the GUI mode , it works awesome. In the non-GUI mode - it throws error. happens in both 64 and 32 bit machines. all other dlls are working in non gui mode. I would love to give any info you need to get this issue fixed. – KitKarson Feb 22 '15 at 00:08
  • @TheBlastOne, thanks for checking this. Yes, i also mentioned the same in my question - in the stacktrace. – KitKarson Apr 26 '15 at 06:50
  • 1
    Seems to me like a bug in OracleInternal.I18N... I don't know if there is anything you can do about it. – Zohar Peled Apr 26 '15 at 07:49
  • 1
    Possible workaround: start hidden, un-hide for just the connect, then re-unhide. Also, you can config qtp to be minimized, I think, and still have "visible" status. – TheBlastOne Apr 26 '15 at 10:02
  • @TheBlastOne, The problem is - I have a `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. – KitKarson Apr 26 '15 at 23:47
  • Qtp can find its own instance of AOM (there is only one), and toggle "visible" from within the action script code, no? – TheBlastOne Apr 26 '15 at 23:52
  • @TheBlastOne, Yes, it is doable. – KitKarson Apr 27 '15 at 00:31
  • Sorry if I am missing something but UFT doesn't support VB.NET. It uses VBScript instead. And in my project i use Adodb object to connect to oracle DB from VBScript. – olyv Nov 05 '16 at 16:10

3 Answers3

1

Because that looks like VB.NET Have you got that code in a form load? That event is unpredictable if you are not showing the form.

-1

have u tried the oracle connection using the ADOB connection object ? you need to have the Oracle driver installed and it will help you to connect to the DB by creation the ADOB connection object

Annette
  • 214
  • 1
  • 3
  • 16
-1

Try this

conn = New Oracle.ManagedDataAccess.Client.OracleConnection(ConnectionString)
Ruban J
  • 622
  • 1
  • 7
  • 31