Solved

ASP.net  OLE DB Provider was not specified

Posted on 2010-11-22
6
610 Views
Last Modified: 2012-05-10
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;'.

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

Open in new window

0
Comment
Question by:murbro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34190407
Can you post your connection string?
0
 

Author Comment

by:murbro
ID: 34190429
 <connectionStrings>
    <clear />
    <add name="WhatEverNameYouWant" connectionString="Microsoft.ACE.OLEDB.12.0;Data Source=Database\Contacts.accdb;" />
  </connectionStrings>

I took the login and password out. I hope that didn't disrupt things
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 34190453
That connection string should say:

connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Database\Contacts.accdb;"
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

Author Comment

by:murbro
ID: 34190576
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.OleDbException' occurred in System.Data.dll
A first chance exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll

Is this a separate issue. Should I post it as a new question
0
 

Author Closing Comment

by:murbro
ID: 34190695
Thanks
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34190704
If you add:
Response.Write(ex.Message)[code]
Between these two lines:
[code]
        Catch ex As Exception

        Finally

Open in new window


It should show you what the actual error message is.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question