mlagrange
asked on
Need example of web.config ConnectionString for Access mdb
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\M yMDB.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
<connectionStrings>
<add name="AppConStr1" connectionString="Provider
</connectionStrings>
and got an error message about the "Provider" argument.
Could somebody post an example with the right yik-yak words, please?
Thanks
Mark
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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(GetConnectio nString))
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_Da ta/MyMDB.m db" 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(DataObje ctMethodTy pe.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(GetConnectio nString))
cmd.Connection.Open()
Dim rdr As SqlDataReader = cmd.ExecuteReader(CommandB ehavior.Cl oseConnect ion)
Return rdr
End Function
Private Shared Function GetConnectionString() As String
Return ConfigurationManager.Conne ctionStrin gs("Access FileName") .Connectio nString
End Function
End Class
Thanks again for all your responses
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(GetConnectio
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_Da
</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(DataObje
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(GetConnectio
cmd.Connection.Open()
Dim rdr As SqlDataReader = cmd.ExecuteReader(CommandB
Return rdr
End Function
Private Shared Function GetConnectionString() As String
Return ConfigurationManager.Conne
End Function
End Class
Thanks again for all your responses
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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
http://www.connectionstrings.com/