Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need example of web.config ConnectionString for Access mdb

Posted on 2006-06-12
6
Medium Priority
?
1,781 Views
Last Modified: 2008-01-16
Hello - I'm trying to set up an Object Data Source against an Access (2003) mdb; I've tried:
  <connectionStrings>
    <add name="AppConStr1" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\MyProject\App_Data\MyMDB.mdb;" />
  </connectionStrings>

and got an error message about the "Provider" argument.

Could somebody post an example with the right yik-yak words, please?

Thanks

Mark
0
Comment
Question by:mlagrange
[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
6 Comments
 
LVL 5

Expert Comment

by:Jojo1771
ID: 16891347
A good site for connection strings. One of my favs.

http://www.connectionstrings.com/
0
 
LVL 27

Assisted Solution

by:Sammy Ageil
Sammy Ageil earned 664 total points
ID: 16892203
You need to have your DB in App_Data directory

<connectionStrings>
  <add name="MyConnectionString"
    connectionString="Provider=Microsoft.Jet.OLEDB.4.0;
      Data Source=|DataDirectory|MyDB.mdb"
    providerName="System.Data.OleDb" />
</connectionStrings>

to retrieve it
Dim strConnString As String = ConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString

HTH
0
 
LVL 7

Assisted Solution

by:pradeepsudharsan
pradeepsudharsan earned 664 total points
ID: 16892512
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:mlagrange
ID: 16893578
Thanks jojo1771, but that's essentially what I had before; I got the same error:
Keyword not supported: 'provider'.

Thanks Sammy1971, but that got a different error message:
Format of the initialization string does not conform to specification starting at index 0.

Both of these error messages point to the line:
Dim cmd As SqlCommand = New SqlCommand(sel, New SqlConnection(GetConnectionString))

I took a wild quess and added a line in the class code for "Imports System.Data.OleDb", but no help.

I'm using code examples that are going against a SQL Server database; obviously, something in these examples is not appropriate for going against an Access database. Here's the whole thing...

In my web.config:

<connectionStrings>
      <remove name="AccessFileName"/>
      <add name="AccessFileName" connectionString="~/App_Data/MyMDB.mdb" providerName="System.Data.OleDb"/>
</connectionStrings>
 

In my Object Data Source class code:

Imports Microsoft.VisualBasic
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OleDb

Public Class clsCensusData

    <DataObjectMethod(DataObjectMethodType.Select)> _
    Public Shared Function TestCensusDataList() As IEnumerable
        Dim sel As String = "SELECT * FROM tblCensusData ORDER BY EmpName"
        Dim cmd As SqlCommand = New SqlCommand(sel, New SqlConnection(GetConnectionString))
        cmd.Connection.Open()
        Dim rdr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
        Return rdr
    End Function

    Private Shared Function GetConnectionString() As String
        Return ConfigurationManager.ConnectionStrings("AccessFileName").ConnectionString
    End Function

End Class

Thanks again for all your responses
0
 
LVL 5

Accepted Solution

by:
Jojo1771 earned 672 total points
ID: 16899411
Are you running 2.0?
 If so I would use admin web site to setup your config stuff. A web based GUI for the web config.

To be honest I only use SQL, so Im not going to be much help. Maybe theres somthing in this doc that can give you some help.

http://www.codeproject.com/cs/database/Connection_Strings.asp
0
 

Author Comment

by:mlagrange
ID: 16929625
Thanks for all your suggestions. I have since realized:

1) The data retrieval command yik-yak would have to be OleDB yik-yak, not SQL yik-yak, and I can't find any examples of that out there (the things you pointed me to might start out with connnection strings for mdb's, but no related command statements for going against an mdb)  

2) I was trying to postpone the inevitable by using an Access mdb "for prototyping"; I need to swim out of the shallow end of Access and into the deep end of SQL Server

Thanks again for your responses  
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

721 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