BUG: Error Message: Error '80004005' Unexpected Error
What a pain in my keister, Meister!!!
Man, talk about no help and no clue why my .aspx page would work about 5 times and then just get this horrible error. It happens when the ,net page tries to open a database connection.
Here's my (now obviusoly wrong code)
Dim myConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\Desktop\Ctest\db\store.MDB"
Dim myConnection As OleDbConnection = New OleDbConnection(myConnectionString)
Dim myCommand As OleDbCommand
Dim myCommand2 As OleDbCommand
Dim myCommand3 As OleDbCommand
Dim result As OleDbDataReader
Dim result2 As OleDbDataReader
Dim result3 As OleDbDataReader
Dim mySelect As String = "Select subgroupsingroups.subgroupname,subgroupsingroups.idsubgroupsingroups from subgroupsingroups where idSubGroupsinGroups in(select idsubgroup from productsinsubgroup where idproduct=" & catid & ")"
myConnection.Open()
'Create an OleDbCommand object.
'Notice that we pass in the SQL statement and the OleDbConnection object.
myCommand = New OleDbCommand
myCommand.Connection = myConnection
myCommand.CommandText = mySelect
result = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
myRepeater.DataSource = result
myRepeater.DataBind()
Dim mySelect2 As String = "SELECT group_title, idgroup FROM allgroups ORDER BY idgroup"
myCommand2 = New OleDbCommand
myCommand2.Connection = myConnection
myCommand2.CommandText = mySelect2
myConnection.Open()
category1.DataValueField = "idgroup"
category1.DataTextField = "group_title"
result2 = myCommand2.ExecuteReader(CommandBehavior.CloseConnection)
category1.DataSource = result2
category1.DataBind()
objConnection.Close()
Dim mySelect3 As String = "SELECT [Partnumber] FROM Products1 where idProduct=" & catid
Dim mySelect4 As String = "SELECT [Title] FROM Products1 where idProduct=" & catid
myCommand3 = New OleDbCommand
myCommand3.Connection = myConnection
myCommand3.CommandText = mySelect3
myConnection.Open()
pronum = myCommand3.ExecuteScalar
myCommand3.CommandText = mySelect4
pronum2 = myCommand3.ExecuteScalar
objConnection.Close()
Label1.Text = pronum
Label2.Text = pronum2
Well, When I copy and paste code from somewhere, I need to be more careful and double check it, but because it is opening a connection and then not closing it (its closing the wrong connection), it give the Error '80004005' Unexpected Error, so I corrected the code:
Dim myConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\Desktop\Ctest\db\store.MDB"
Dim myConnection As OleDbConnection = New OleDbConnection(myConnectionString)
Dim myConnection2 As OleDbConnection = New OleDbConnection(myConnectionString)
Dim myConnection3 As OleDbConnection = New OleDbConnection(myConnectionString)
Dim myCommand As OleDbCommand
Dim myCommand2 As OleDbCommand
Dim myCommand3 As OleDbCommand
Dim result As OleDbDataReader
Dim result2 As OleDbDataReader
Dim result3 As OleDbDataReader
Dim mySelect As String = "Select subgroupsingroups.subgroupname,subgroupsingroups.idsubgroupsingroups from subgroupsingroups where idSubGroupsinGroups in(select idsubgroup from productsinsubgroup where idproduct=" & catid & ")"
myConnection.Open()
'Create an OleDbCommand object.
'Notice that we pass in the SQL statement and the OleDbConnection object.
myCommand = New OleDbCommand
myCommand.Connection = myConnection
myCommand.CommandText = mySelect
result = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
myRepeater.DataSource = result
myRepeater.DataBind()
Dim mySelect2 As String = "SELECT group_title, idgroup FROM allgroups ORDER BY idgroup"
myCommand2 = New OleDbCommand
myCommand2.Connection = myConnection2
myCommand2.CommandText = mySelect2
myConnection2.Open()
category1.DataValueField = "idgroup"
category1.DataTextField = "group_title"
result2 = myCommand2.ExecuteReader(CommandBehavior.CloseConnection)
category1.DataSource = result2
category1.DataBind()
myConnection2.Close()
Dim mySelect3 As String = "SELECT [Partnumber] FROM Products1 where idProduct=" & catid
Dim mySelect4 As String = "SELECT [Title] FROM Products1 where idProduct=" & catid
myCommand3 = New OleDbCommand
myCommand3.Connection = myConnection3
myCommand3.CommandText = mySelect3
myConnection3.Open()
pronum = myCommand3.ExecuteScalar
myConnection3.Close()
myCommand.CommandText = mySelect4
myConnection.Open()
pronum2 = myCommand.ExecuteScalar
myConnection.Close()
Label1.Text = pronum
Label2.Text = pronum2
Works like a charm!!!
It would be nice if Microsoft could give a little more to go on!!