Unspecified Error: E_FAIL(0x80004005)

S

Sunny

I keep on getting the error E_FAIL(0x80004005) whenever I
try to run a query on a database that has three fields
Number Firstname Lastname

under the table "Names"

Here's my code for the dataservice class
Imports System.Data
Imports System.Data.OleDb
Imports System.Configuration

Public Class DataService

Private connectionString As String

Public Sub New()
connectionString
= "Provider=Microsoft.Jet.OLEDB.4.0;Password=;User
ID=Admin;Data Source=C:\Documents and Settings\Paul
Do\Desktop\db1.mdb;Mode=ReadWrite|Share Deny None;;Jet
OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet
OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk
Transactions=1;Jet OLEDB:New Database Password=;Jet
OLEDB:Create System Database=False;Jet OLEDB:Encrypt
Database=False;Jet OLEDB:Don't Copy Locale on
Compact=False;Jet OLEDB:Compact Without Replica
Repair=False;Jet OLEDB:SFP=False"
If (connectionString = String.Empty) Then
Throw New ApplicationException("Missing
the 'db_connection' from the <appSettings> section in
app.config")
End If
End Sub

Public Function GetConnection() As OleDbConnection
Dim connection As OleDbConnection = New
OleDbConnection(connectionString)
Return connection
End Function

End Class





and here's how it's being used

Dim db As New DataService()

Dim connection As OleDbConnection =
db.GetConnection()
Try
connection.Open()
MessageBox.Show("Database open")
Catch dbEx As System.Data.OleDb.OleDbException
MessageBox.Show(dbEx.Message)
End Try

Try
Dim cmd As New OleDbCommand("select count(*)
from Names", connection)
Dim count As Integer = cmd.ExecuteScalar()
MessageBox.Show(String.Format("There are {0}
records in the table", count))
Catch dberr As System.Data.OleDb.OleDbException
MessageBox.Show(dberr.Message)
Finally
MessageBox.Show("Closing Database")
connection.Close()

End Try


Any help on this would be appreciated
 
S

scorpion53061

You are using reserved words.

Change Names to another name.
Change Number to another name.
and try again or put brackets around your field names and it should work.

Let me know if this helped.
 
S

scorpion53061

Well it certainly is a theory....though lacking in any substance.

I take it you and Sunny know each other?
 
G

Guest

yea, a bit. he's kinda dumb so any help you can give him
is greatly appreciated. he cries when he can't find an
answer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top