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 OLEDBatabase 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 OLEDBon'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
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 OLEDBatabase 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 OLEDBon'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