ADO problem

  • Thread starter Thread starter Joel Whitehouse
  • Start date Start date
J

Joel Whitehouse

Hello all:


After the 38th iteration of a loop that calls this code, I get the
following error:

An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in Antenna Test
Range Control.exe

Additional information: Unspecified error


Here's my code:

Private Sub SendQuery(ByVal query As String)
Dim command As New ADODB.Command
'Create a connection object
Dim adoConnection As New ADODB.Connection
adoConnection.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and
Settings\Antenna\My Documents\testdata.mdb;"

adoConnection.Open() '<-----------------Error happens here
command.ActiveConnection = adoConnection
command.ActiveConnection.BeginTrans()
command.CommandText = query
command.CommandType = CommandTypeEnum.adCmdText
command.Execute()
command.ActiveConnection.CommitTrans()

If adoConnection.State = ObjectStateEnum.adStateOpen Then
adoConnection.Close()
end if
adoConnection = Nothing
End Sub


Any ideas? Thanks!


-Joel
 
wait a min, you're dealing with MS access. make sure your access dB doesn't
have a DAO *.mdw password authentication. ADO don't go with the concept of
workgroup. Maybe there is a trick to get ADO.net to do that but not that I
am awared off hand. You could work around this thru adodb class, but then
again what's the point to going to ADo when there is ADO.net that is much
more powerful.

Now if you're not using an *.mdw password authentication mechanism then, try
using the explorer (GUI db connector) to see if you could make your
connection cuz based on what I saw here is VB couldn't opened your db so
there must be some authentication issues. try testing northwind.mdb, which
isn't encrypted with password, and see for yourself. your codes should open
it.

-Ben
 
Joel,

I have the idea that this is not your complete code, otherwise you would not
use this.
If adoConnection.State = ObjectStateEnum.adStateOpen Then
adoConnection.Close()

However, close it without condition.

Just my thought,

Cor
 
Ben said:
wait a min, you're dealing with MS access. make sure your access dB doesn't
have a DAO *.mdw password authentication. ADO don't go with the concept of
workgroup. Maybe there is a trick to get ADO.net to do that but not that I
am awared off hand. You could work around this thru adodb class, but then
again what's the point to going to ADo when there is ADO.net that is much
more powerful.

Ben, I don't have any passwords setup... This code seems to work.

I modified the code and added a count variable. When the error occurs,
the variable count = 60. Get that! 60! In addition, I can see teh
effects of every query that this code sends. Why would this run a full
60 times and then break?



Private Sub SendQuery(ByVal query As String)
Static count As Integer

Dim command As New ADODB.Command
'Create a connection object
Dim adoConnection As New ADODB.Connection

adoConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Documents and Settings\Antenna\My Documents\testdata.mdb;"

adoConnection.Open() '<-----------------Error happens here
command.ActiveConnection = adoConnection
command.ActiveConnection.BeginTrans()
command.CommandText = query
command.CommandType = CommandTypeEnum.adCmdText
command.Execute()
command.ActiveConnection.CommitTrans()

If adoConnection.State = ObjectStateEnum.adStateOpen Then
adoConnection.Close()
adoConnection = Nothing

count = count + 1 '<------------Count increments to 60 -
'but error occurs before it can
'increment to 61
End Sub
 
Further experimentation *always* breaks the sendquery function on the
61st call. Why?
 
¤ Hello all:
¤
¤
¤ After the 38th iteration of a loop that calls this code, I get the
¤ following error:
¤
¤ An unhandled exception of type
¤ 'System.Runtime.InteropServices.COMException' occurred in Antenna Test
¤ Range Control.exe
¤
¤ Additional information: Unspecified error
¤
¤
¤ Here's my code:
¤
¤ Private Sub SendQuery(ByVal query As String)
¤ Dim command As New ADODB.Command
¤ 'Create a connection object
¤ Dim adoConnection As New ADODB.Connection
¤ adoConnection.ConnectionString =
¤ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and
¤ Settings\Antenna\My Documents\testdata.mdb;"
¤
¤ adoConnection.Open() '<-----------------Error happens here
¤ command.ActiveConnection = adoConnection
¤ command.ActiveConnection.BeginTrans()
¤ command.CommandText = query
¤ command.CommandType = CommandTypeEnum.adCmdText
¤ command.Execute()
¤ command.ActiveConnection.CommitTrans()
¤
¤ If adoConnection.State = ObjectStateEnum.adStateOpen Then
¤ adoConnection.Close()
¤ end if
¤ adoConnection = Nothing
¤ End Sub
¤
¤
¤ Any ideas? Thanks!

Try running System.Runtime.InteropServices.Marshal.ReleaseComObject on your adoConnection object
after you close it and set it to Nothing.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Paul said:
Try running System.Runtime.InteropServices.Marshal.ReleaseComObject on your adoConnection object
after you close it and set it to Nothing.


Paul
~~~~
Microsoft MVP (Visual Basic)

This technique appears to release the resources effectively, but I still
get the unspecified error on the 60th try...

I'm so stuck here, and I only have 2 weeks to get this thing working....
Ugh!

-Joel
 
Back
Top