Murray Brown
asked on
ASP.net OLE DB Provider was not specified
Hi
I am getting the following error in the code mentioned in the code section at the first line
of the button click event.
An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'.
I am getting the following error in the code mentioned in the code section at the first line
of the button click event.
An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'.
Imports System.Data
Imports System.Data.OleDb
Imports System.Configuration
Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
'// define a connection to the database
Dim cn As New OleDbConnection(ConfigurationManager.ConnectionStrings("WhatEverNameYouWant").ConnectionString)
'// define the sql statement to execute
Dim cmd As New OleDbCommand("SELECT * FROM [Contacts]", cn)
Try
'// open the connection
cn.Open()
'// execute the sql statement
Using reader As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
While reader.Read()
'// this loops through all of the returned records
End While
End Using
Catch ex As Exception
Finally
If cn.State <> ConnectionState.Closed Then
cn.Close()
End If
End Try
End Sub
Can you post your connection string?
ASKER
<connectionStrings>
<clear />
<add name="WhatEverNameYouWant" connectionString="Microsof t.ACE.OLED B.12.0;Dat a Source=Database\Contacts.a ccdb;" />
</connectionStrings>
I took the login and password out. I hope that didn't disrupt things
<clear />
<add name="WhatEverNameYouWant"
</connectionStrings>
I took the login and password out. I hope that didn't disrupt things
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi
Thanks. That helped. I am now getting a message in the "Immediate Window" section at the bottom of the screen>\.
A first chance exception of type 'System.ArgumentException' occurred in System.Data.dll
A first chance exception of type 'System.Data.OleDb.OleDbEx ception' occurred in System.Data.dll
A first chance exception of type 'System.Data.OleDb.OleDbEx ception' occurred in System.Data.dll
Is this a separate issue. Should I post it as a new question
Thanks. That helped. I am now getting a message in the "Immediate Window" section at the bottom of the screen>\.
A first chance exception of type 'System.ArgumentException'
A first chance exception of type 'System.Data.OleDb.OleDbEx
A first chance exception of type 'System.Data.OleDb.OleDbEx
Is this a separate issue. Should I post it as a new question
ASKER
Thanks
If you add:
It should show you what the actual error message is.
Response.Write(ex.Message)[code]
Between these two lines:
[code]
Catch ex As Exception
Finally
It should show you what the actual error message is.