Solved

ASP.net  OLE DB Provider was not specified

Posted on 2010-11-22
6
604 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
  • 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now