Connecting to an Access mdb web.config

M

msch-prv

I have difficulties declaring and using an Access connection string.
The web.config declaration is:

<connectionStrings>
<add name="DbConn"
connectionString="~/App_Data/CRM2K_be.mdb"
providerName="System.Data.OleDb"/>
</connectionStrings>

In the Page_Load event, I have the following:

Dim sqlSrc As SqlDataSource
sqlSrc = New
SqlDataSource(ConfigurationManager.ConnectionStrings("DbConn").ConnectionString,
"SELECT CustLName FROM tblCust")
grd2.DataSource = sqlSrc
grd2.DataBind()

When I run the page, an initialization error pops up: 'Format of the
initialization string does not conform to specification starting at
index 0'

What is the proper syntax (ASP.NET 2.0)? Are there some Access sample
apps to demonstrate these pinciples? Most of the samples rely on SQL
Express.

(Side comment: As a newbie, I find ASP.NET 2.0 really tough to get a
hang on. The MS literature is overwhelming, but not really useful if
you are learning the basics.)

TIA, Mark
 
M

msch-prv

Sorry, I found the answer to my question. By mistake, I used a
SqlDataSource object instead of AccessDataSource.

Substituting back makes it work ie:
sqlSrcAcc = New
AccessDataSource(ConfigurationManager.ConnectionStrings("DbConn").ConnectionString,
"SELECT CustLName FROM tblCust")

Question: Instead of using explicit SQL statements, would it be
possible to import Access queries into the sqlSrcAcc object?

TIA, Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top