473,396 Members | 2,140 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Webconfig Connection String

My application uses two ways to connect to the Access db:

Programtically:

Dim sDBPath = "Data Source=D:\MCCL\AccessDB\NewMCCL.mdb;"
Dim sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & sDBPath
Dim myConnection As New OleDbConnection(sConnString)

By Declaring:

<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/NewMCCL.mdb"
SelectCommand="SELECT * FROM [web_MatchReportingByWeekID]">
</asp:AccessDataSource>
What entry do I put into my webconfig file so I can call it from within my
code?

How do I use this for both types of the above versions?

PWS
Oct 27 '07 #1
5 2980
On 27 Oct, 17:13, "Paul W Smith" <p...@NOSPAM.twelve.me.ukwrote:
My application uses two ways to connect to the Access db:

Programtically:

Dim sDBPath = "Data Source=D:\MCCL\AccessDB\NewMCCL.mdb;"
Dim sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & sDBPath
Dim myConnection As New OleDbConnection(sConnString)

By Declaring:

<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/NewMCCL.mdb"
SelectCommand="SELECT * FROM [web_MatchReportingByWeekID]">
</asp:AccessDataSource>

What entry do I put into my webconfig file so I can call it from within my
code?

How do I use this for both types of the above versions?

PWS
It appears from your two declarations that you have two copies of the
file NewMCCL.mdb in different locations.

Assuming that when you deploy the site it will be in "~/App_Data/
NewMCCL.mdb" it would be simpler to modify the code for sDBPath to:

sDBPath = "D:\Data Source=" & Server.MapPath("~/App_Data/
NewMCCL.mdb;")

Unless the datafile name is likely to change it isn't worth putting it
in web.config because the entries won't be the same for
AccessDataSource1 and MyConnection (the latter requires a full
connection string whereas the former only needs the datafile path).

HTH

Oct 27 '07 #2
Howdy,

web.config:

<connectionStrings>
<add name="myConnectionString"
connectionString="server=whateever;datasource=blab la"/>
</connectionStrings>

aspx page:

<asp:AccessDataSource runat="server" ID="ds"
ConnectionString="<%$ ConnectionStrings:myConnectionString %>">
</asp:AccessDataSource>
vb.net code:

Dim connectionString As String = _
ConfigurationManager.ConnectionStrings("myConnecti onString").ConnectionString

ds.ConnectionString = connectionString

Hope this helps
--
Milosz
"Paul W Smith" wrote:
My application uses two ways to connect to the Access db:

Programtically:

Dim sDBPath = "Data Source=D:\MCCL\AccessDB\NewMCCL.mdb;"
Dim sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & sDBPath
Dim myConnection As New OleDbConnection(sConnString)

By Declaring:

<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/NewMCCL.mdb"
SelectCommand="SELECT * FROM [web_MatchReportingByWeekID]">
</asp:AccessDataSource>
What entry do I put into my webconfig file so I can call it from within my
code?

How do I use this for both types of the above versions?

PWS
Oct 27 '07 #3
>sDBPath = "D:\Data Source=" & Server.MapPath("~/App_Data/NewMCCL.mdb;")

Are you sure about the line above, because I cannot get it to work.

Where did you get the "D:\" from?
Oct 27 '07 #4
"Paul W Smith" <pw*@NOSPAM.twelve.me.ukwrote in message
news:ex*************@TK2MSFTNGP04.phx.gbl...
sDBPath = "D:\Data Source=" & Server.MapPath("~/App_Data/NewMCCL.mdb;")

Are you sure about the line above, because I cannot get it to work.

Where did you get the "D:\" from?

Maybe from the third line of your OP...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 27 '07 #5
On 27 Oct, 20:45, "Paul W Smith" <p...@NOSPAM.twelve.me.ukwrote:
sDBPath = "D:\Data Source=" & Server.MapPath("~/App_Data/NewMCCL.mdb;")

Are you sure about the line above, because I cannot get it to work.

Where did you get the "D:\" from?
Yes, I beg your pardon. It should have been:

sDBPath = "Data Source=" & Server.MapPath("~/App_Data/NewMCCL.mdb;")

Yours humbly
Phil Hall
Oct 27 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jim Heavey | last post by:
I am trying to figure out how to "deal" with placing the connection string into the webconfig file when the connection string contains " and '. Here is my connection string... //...
1
by: brian | last post by:
I have a webconfig file in my root directory in IIS with session state set for 100 minutes. All login information is stored in session variables for the site. I have a page that is used by our...
6
Cintury
by: Cintury | last post by:
Hi all, I've developed a mobile application for windows mobile 5.0 that has been in use for a while (1 year and a couple of months). It was developed in visual studios 2005 with a back-end sql...
1
by: rapaka.srinivas | last post by:
Hi i am having a problem with dynamic webconfig.What i am doing exactly is i am calling a fucntion in app_start event that will fetch connection string from my system registry and updates my...
0
by: jambalapamba | last post by:
Hi I am trying to acess my webconfig file in aspx page .I know we can acess in code behind using ConfigurationManager.ConnectionStrings.ConnectionString; but i want to acess in aspx...
4
by: =?Utf-8?B?bWFkaHVzcnA=?= | last post by:
Hi, Could anyone suggest me an idea to encrypt the webconfig file's connection string in the framework 1.1. Thank you in Advance -- Lets Learn and Make All Learn
1
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, in fx 1.1 how did you know when you retrived the connection string from the web.config what kind of database it was? thanks rodchar
2
by: pavanip | last post by:
I placed my asp.net code in my server and i placed my database stuff in web hosting server.I created a virtual directory in web hosting server to access my files from my server.I have written the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.