If a SQLDataSource add the following to my web.config file, how to I
programmatically extract the connection string:
<configuration>
<appSettings/>
<connectionStrings>
<add name="GUIDBConnectionString" connectionString="Data
Source=(local);Initial Catalog=GUI;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings> 7 12583
Hello John,
To get that string try:
// Get the connectionString.
ConnectionStringSettings connectionStringSettings =
ConfigurationManager.ConnectionStrings["GUIDBConnectionString"];
Then to use it:
// Initialize the connection with the string
SqlConnection sqlConnection - new
SqlConnection(connectionStringSettings.ConnectionS tring);
--
I think that should do it - brians http://www.limbertech.com
"John A Grandy" wrote: If a SQLDataSource add the following to my web.config file, how to I programmatically extract the connection string:
<configuration>
<appSettings/>
<connectionStrings>
<add name="GUIDBConnectionString" connectionString="Data Source=(local);Initial Catalog=GUI;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
Here is what works for me;
--->In your WEB.CONFIG file
<appSettings>
<add key="DBConn" value="Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=c:\inetpub\wwwroot\data\test.mdb" />
</appSettings>
-->In your page
Dim objConn As OleDBConnection = New
OleDBConnection(ConfigurationSettings.AppSettings( "DBConn"))
Hope this helps,
Jeremy Reid http://blackstaronline.net/hgtit
Sorry, I am very much in the mindset of ASP.NET 2.0. they have added some
nice additional configuration management features. For 1.1 try:
web.config:
<appSettings>
<add key="ConnectionString" value="server=...;database=...;user id=...;
password=...;" />
</appSettings>
In your connection code:
SqlConnection conn = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
--
brians http://www.limbertech.com
"brians[MCSD]" wrote: Hello John,
To get that string try:
// Get the connectionString. ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["GUIDBConnectionString"];
Then to use it: // Initialize the connection with the string SqlConnection sqlConnection - new SqlConnection(connectionStringSettings.ConnectionS tring);
-- I think that should do it - brians http://www.limbertech.com
"John A Grandy" wrote:
If a SQLDataSource add the following to my web.config file, how to I programmatically extract the connection string:
<configuration>
<appSettings/>
<connectionStrings>
<add name="GUIDBConnectionString" connectionString="Data Source=(local);Initial Catalog=GUI;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
Yes. I am doing 2.0 , so this is what I want. Thanks.
"brians[MCSD]" <br********@discussions.microsoft.com> wrote in message
news:4B**********************************@microsof t.com... Hello John,
To get that string try:
// Get the connectionString. ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["GUIDBConnectionString"];
Then to use it: // Initialize the connection with the string SqlConnection sqlConnection - new SqlConnection(connectionStringSettings.ConnectionS tring);
-- I think that should do it - brians http://www.limbertech.com
"John A Grandy" wrote:
If a SQLDataSource add the following to my web.config file, how to I programmatically extract the connection string:
<configuration>
<appSettings/>
<connectionStrings>
<add name="GUIDBConnectionString" connectionString="Data Source=(local);Initial Catalog=GUI;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
John A Grandy wrote: Yes. I am doing 2.0 , so this is what I want. Thanks.
"brians[MCSD]" <br********@discussions.microsoft.com> wrote in message news:4B**********************************@microsof t.com... Hello John,
To get that string try:
// Get the connectionString. ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings["GUIDBConnectionString"];
Then to use it: // Initialize the connection with the string SqlConnection sqlConnection - new SqlConnection(connectionStringSettings.ConnectionS tring);
-- I think that should do it - brians http://www.limbertech.com
"John A Grandy" wrote:
If a SQLDataSource add the following to my web.config file, how to I programmatically extract the connection string:
<configuration>
<appSettings/>
<connectionStrings>
<add name="GUIDBConnectionString" connectionString="Data Source=(local);Initial Catalog=GUI;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
I tried to use:
SqlConnection conn = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"])
in my connection code, but I got the error message below.
'Public Shared ReadOnly Property AppSettings() As
System.Collections.Specialized.NameValueCollection ' is obsolete: 'This
method is obsolete, it has been replaced by
System.Configuration!System.Configuration.Configur ationManager.AppSettings'
Is there something I should be doing differently in asp.net 2.0?
I have found it easier to give up altogether on appSettings,
and use connectionStrings instead, although you can use either.
For VB and C# examples, see : http://www.asp.net/QuickStart/aspnet.../retrieve.aspx
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
<ra******@yahoo.com> wrote in message news:11**********************@i40g2000cwc.googlegr oups.com... I tried to use: SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]) in my connection code, but I got the error message below.
'Public Shared ReadOnly Property AppSettings() As System.Collections.Specialized.NameValueCollection ' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.Configur ationManager.AppSettings'
Is there something I should be doing differently in asp.net 2.0? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Varun |
last post by:
I have a solution which contains windows,web,mobile presentations. Now i want to share the connection string in the web.config file.
i want to write a method in a common layer where i can retrieve...
|
by: VK |
last post by:
Dear All:
We are in the processing of building a new web site using VB.NET and
SQL2000
I had a question about WHERE to store the connection string for SQL dB -
in an include file or...
|
by: H |
last post by:
This is a question that has haunted me for quite some time.
if you build a 4 tier database application where the 4th tier is the
database server (MS SQL 2000), where do you build the connection...
|
by: Charlie |
last post by:
Hi:
My host will not allow me use a trusted connection or make registry setting,
so I'm stuck trying find a way to hide connection string which will be
stored in web.config file. If I encrypt...
|
by: Jaime Stuardo |
last post by:
Hi all..
I have created a business logic component that is used from my ASP.NET
webform. It works, but connection string to the database is hard coded, as
in this method :
public DataSet...
|
by: WebMatrix |
last post by:
Hello,
I have developed a web application that connects to 2 different database
servers. The connection strings with db username + password are stored in
web.config file.
After a code review,...
|
by: sam44 |
last post by:
Hi,
At startup the user log on and chooses the name of a client from a
dropdownlist, which then changes dynamically the connection string (the
name of the client indicates which database to use)....
|
by: Thorsten Dittmar |
last post by:
Hi,
I don't get it. I'm using a typed dataset with table adapters and all
that stuff. I have the database server running locally on my development
system.
Now: when creating a tableadapter...
|
by: Brett |
last post by:
I wrote an ASP.NET application that queries a SQL Server database (on a
different box from the web server) and displays the result in a GridView.
The datasource for the GridView is a SQLDataSource....
|
by: Johnson |
last post by:
I'm trying to fix a "sub optimal" situation with respect to connection
string management. Your thoughtful responses will be appreciated.
I just started with a new client who has a bunch of legacy...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |