!vb.net调用com组件出现的奇怪有关问题
紧急求助!vb.net调用com组件出现的奇怪问题!
情况是这样,
有个com组件,完全独立的,提供给外部第3方单位使用,
会进行oracle数据库操作。
利用vb.net单独调用该com组件是完全没有问题的。
但是:
如果vb.net先操作其它的数据库,比如Access,再调用com组件的时候,com组件内的oracle操作就会出现问题。
这是为什么吗呢?
1,vb.net单独使用com组件的代码如下:
Dim myCom As New pjkpjk.xmfs_pjkpjk
Dim ls_requestXml As String
ls_requestXml = "requtst"
Try
Dim li_result As String
li_result = myCom.service(ls_requestXml)
MessageBox.Show(li_result)
Catch ex As Exception
MsgBox("yichang:" & ex.Message)
End Try
2,vb.net单独操作Access数据库的代码如下:
Const SQL_CONNECTION_STRING As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\114webser\#SMS#.MDB;Persist Security Info=False;"
Dim myCONN1 As New OleDbConnection(SQL_CONNECTION_STRING)
Dim mySQL1 As String = "select * from user_table"
Dim COMM1 As OleDbCommand = New OleDbCommand(mySQL1, myCONN1)
If COMM1 Is Nothing Then
MsgBox("dfasldfasdf")
Else
'MsgBox("ok")
End If
Dim DR1 As OleDbDataReader
Try
myCONN1.Open()
DR1 = COMM1.ExecuteReader()
If DR1.Read Then
MsgBox("ok5" & DR1.GetString(2))
'Dim data As Byte() = DR.GetValue(0)
'Using ms As New MemoryStream(data)
' PictureBox1.Image = Image.FromStream(ms)
'End Using
DR1.Close()
COMM1.Cancel()
myCONN1.Close()
DR1 = Nothing
COMM1 = Nothing
myCONN1 = Nothing
Print_Pj()
Else
MsgBox("nothing")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
3,如上所示,两段代码都是没有问题的,单独运行都好好的,但是放在一起前后调用就会出错:
Const SQL_CONNECTION_STRING As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\114webser\#SMS#.MDB;Persist Security Info=False;"
Dim myCONN1 As New OleDbConnection(SQL_CONNECTION_STRING)
Dim mySQL1 As String = "select * from user_table"
Dim COMM1 As OleDbCommand = New OleDbCommand(mySQL1, myCONN1)
If COMM1 Is Nothing Then
MsgBox("dfasldfasdf")
Else
'MsgBox("ok")
End If
Dim DR1 As OleDbDataReader
情况是这样,
有个com组件,完全独立的,提供给外部第3方单位使用,
会进行oracle数据库操作。
利用vb.net单独调用该com组件是完全没有问题的。
但是:
如果vb.net先操作其它的数据库,比如Access,再调用com组件的时候,com组件内的oracle操作就会出现问题。
这是为什么吗呢?
1,vb.net单独使用com组件的代码如下:
Dim myCom As New pjkpjk.xmfs_pjkpjk
Dim ls_requestXml As String
ls_requestXml = "requtst"
Try
Dim li_result As String
li_result = myCom.service(ls_requestXml)
MessageBox.Show(li_result)
Catch ex As Exception
MsgBox("yichang:" & ex.Message)
End Try
2,vb.net单独操作Access数据库的代码如下:
Const SQL_CONNECTION_STRING As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\114webser\#SMS#.MDB;Persist Security Info=False;"
Dim myCONN1 As New OleDbConnection(SQL_CONNECTION_STRING)
Dim mySQL1 As String = "select * from user_table"
Dim COMM1 As OleDbCommand = New OleDbCommand(mySQL1, myCONN1)
If COMM1 Is Nothing Then
MsgBox("dfasldfasdf")
Else
'MsgBox("ok")
End If
Dim DR1 As OleDbDataReader
Try
myCONN1.Open()
DR1 = COMM1.ExecuteReader()
If DR1.Read Then
MsgBox("ok5" & DR1.GetString(2))
'Dim data As Byte() = DR.GetValue(0)
'Using ms As New MemoryStream(data)
' PictureBox1.Image = Image.FromStream(ms)
'End Using
DR1.Close()
COMM1.Cancel()
myCONN1.Close()
DR1 = Nothing
COMM1 = Nothing
myCONN1 = Nothing
Print_Pj()
Else
MsgBox("nothing")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
3,如上所示,两段代码都是没有问题的,单独运行都好好的,但是放在一起前后调用就会出错:
Const SQL_CONNECTION_STRING As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\114webser\#SMS#.MDB;Persist Security Info=False;"
Dim myCONN1 As New OleDbConnection(SQL_CONNECTION_STRING)
Dim mySQL1 As String = "select * from user_table"
Dim COMM1 As OleDbCommand = New OleDbCommand(mySQL1, myCONN1)
If COMM1 Is Nothing Then
MsgBox("dfasldfasdf")
Else
'MsgBox("ok")
End If
Dim DR1 As OleDbDataReader