vb.net – oracle连接打开错误

前端之家收集整理的这篇文章主要介绍了vb.net – oracle连接打开错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用QTP / UFT进行应用程序测试.
我必须访问我的oracle DB(11g)来进行一些数据库设置(更新记录).

我使用oracle.manageddataaccess.dll(引用myDBWrapper类库项目).

我有下面的dlls

(myDBWrapper是我创建的 – 存在问题的地方)

我的连接字符串:

Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=<HOST>)(PORT=<PORT>>)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=<SERVICENAME>)));User Id=<USERNAME>;Password=<PASSWORD>;

问题:

conn.open()期间的以下代码抛出错误.它有时会起作用有时会在同一台机器上抛出“对象引用不设置对象实例”的错误.

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()

注意:

这不是资源泄漏.我只是建立一个连接并处理掉.没有其他人连接到数据库.

问题发生 – 当QTP有COM lib时.当我用它来自动化&使它不可见(QTP.Visible = FALSE).如果我使用QTP.Visible = TRUE – 问题不会发生.这是什么问题!

堆栈跟踪 :

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()
因为它看起来像VB.NET你有一个表单加载的代码吗?如果您没有显示表单,那么该事件是不可预测的.
原文链接:https://www.f2er.com/vb/255422.html

猜你在找的VB相关文章