Web Forms :: Retrieving Web.config Connections Strings?

Feb 24, 2011

I nearly completed my project and was about to put it out to be run. My boss was going to make a minor change to the connection string and then put it out there. In short, my application was running off a dummy database, while the real database was out there. I have the connection string comiple and built through out my project in the aspx pages and the cs pages.

However, my boss wants to be able to change a single connection string in a single place, essentially in the web.config file. I'm fine with that, but I don't know how to access the connection strings stored in the web.config files. How do you do that? So far, I've only created a new connectionstring in my code on each page. I've told him you could do a "find and replace" on all the files but he doesn't want to do that. In short, he wants to change the connection string the same way he does all the other projects he works with, php, vb and etc.

how do you access the connection strings stored in the web.config file programmatically?

View 2 Replies


Similar Messages:

Security :: Data Connections Strings / Web Config?

Apr 4, 2010

I am helping a club create a site that has a password protected "members only area". I have never done anything password protected. I used VWD and created the user names and passwords. Apparently using the AspNetSqlProvider. The site and password protected area work great when tested locally. The problem is when the site is uploaded to the hosting company, the login area will not work. I found that I had to create an SQL database in the appropriate area of the hosting company. The login still won't work. I am thinking that I have to create a connection string in the web config file. The problem is - when I tried that the site wouldn't work when I tested it locally. I really need lots of help with this part.

View 5 Replies

DataSource Controls :: Retrieving Strings From Database Table Instead DateTime - Formatting

Mar 23, 2010

On UI Ajax calendar control is used to allow the user Expiry Date as shown below. As this is one of the controls in search, when the Search button is pressed using SQL statement (copied below) data is retrieved from ExpiryDate column of the table. The table creator declared the column type as string and the dates are saved as single digits(Example: 2/2/10 sometimes and sometime as double digits (Example: 02/02/10) I like to know the best practice in retrieving both type of strings from database table. Calendar control

[Code]....

SQL(part of stored proc)

[Code]....

with in button click event stored procedure is called to return search results.

View 7 Replies

C# - Encrypt The Connection Strings In Web.config?

Dec 20, 2010

I'm trying to encrypt the connection strings in my web.config. I'm following:

http://msdn.microsoft.com/en-us/library/2w117ede.aspx

however when I get to the part with the command:

aspnet_regiis -pe "connectionStrings" -app "/MyApplication" -prov "MyProvider"

it keeps complaining:

"The configuration for the virtual path '/MyApplication' and site 'Default Web Site' cannot be opened

Failed to map the path '/myapplication'
Failed!

I'm fairly sure I've followed the instructions correctly. I created the project named 'MyApplication' directly in the 'C:' root.

Perhaps I should be following a different set of instructions?

View 3 Replies

C# - Two Connection Strings In Web.Config And Switch Between Them In Code Behind?

Nov 19, 2010

How Can We Have two Connection Strings In Web.Config And Switch Betweeen Them In Code Behind? when i add two connention strings in web.config so an error appears that tells us u cann't add two connection strings in web.config. i want the upper job because i have 2 databases and i want transfer data from another to the other one.

View 4 Replies

Storing A Variable Collection Of Strings In Web.Config?

Aug 25, 2010

I would like to store a collection of strings in the web.config. This collection would vary in size over time. I would like to be able to pull all of the strings in the collection into an array or collection in code. (.Net 4, asp.net)
i.e.

<customCodes>
<VendorCode vendorName="Name1" code="1234567891234567891324567987ddd" isActive="true"/>
<VendorCode vendorName="Name2" code="1sadfsadf1234567891324567987ddd" isActive="true" />
<VendorCode vendorName="Name3" code="123456789dfadfdsaf3324567987d32" isActive="true"/>
</customCodes>

I could use appsettings with the strings all in one value but I would like to seperate it out for organizational reasons. Not using the key/value pair complicates things a bit. I am now getting a message that states "you can't have duplicate elements in a section"

View 2 Replies

Web Config - Where Should Connection Strings Be Stored In A N-tier Application

Sep 29, 2010

I have an ASP.NET project which is pretty n-tier, by namespace, but I need to separate into three projects: Data Layer, Middle Tier and Front End.

I am doing this because...

A) It seems the right thing to do, and

B) I am having all sorts of problems running unit tests for ASP.NET hosted assemblies.

Anyway, my question is, where do you keep your config info?

Right now, for example, my middle tier classes (which uses Linq to SQL) automatically pull their connection string information from the web.config when instantiating a new data context.

If my data layer is in another project can/should it be using the web.config for configuration info?

If so, how will a unit test, (typically in a separate assembly) provide soch configuration info?

View 3 Replies

C# - Switch Between 2 Connection Strings In Web.Config (Activate One For DBML)

May 21, 2010

I have two connection strings (both in Web.Config: CS_Local and CS_Production) for my DBML (Linq to SQL). In my Global.Asax/Application_Start I run some production preparation methods if the request is non-local (!HttpContext.Current.Request.IsLocal). Within that part, I'd also like to change the current connection string used by my DBML from the standard CS_Local to CS_Production.

View 1 Replies

Access :: Multiple Connection Strings In Web.config File

Jan 12, 2010

Is that possible to add two connectionstrings in web.config and Can I call those two web.config in my aspx.cs file?

View 3 Replies

Security :: Hashing Web.config Credentials / Connection Strings

Jun 23, 2010

I want to apply some better security measures to an existing web application. Currently, my connection string contains the user name and password in plain text. I'm also using a custom membership provider, which stores user names and passwords in the web.config file as plain text [URL] I would like to secure this information using an algorithm such as SHA1.

View 1 Replies

Configuration :: Web.config Connection Strings For Development And Production Environments

Apr 15, 2010

I have seen the examples on how to switch between connections strings for development and production enviroments. My web.config also calls out a connection string for <roleManager and membership><providers>. Can this be setup to switch between the two connection strings?

View 1 Replies

Configuration :: Two Connection Strings In 4.0 Web.config File Using Ms Sql 2008 Express

Jan 21, 2011

I would like to use both of the connection strings in the same web.config file how can I do this I tried this yesterday it worked I called it a night, then this morning I got this. The error being on line: 10 Parser Error Message: The entry 'ApplicationServices' has already been added.

Line 8: <add name="ApplicationServices"
Line 9: connectionString="Data Source=Mysource;Initial Catalog=travelatlantic;User ID=MyID; Password=MyPassword;" />
Line 10: <add name="ApplicationServices"
Line 11: connectionString="Data Source=MySource;Initial Catalog=travelatlantic2;User ID=Myid; Password=MyPassword;" />
Line 12: </connectionStrings>

View 8 Replies

Security :: Saving Stored Procedure Names And Connection Strings In Config Files

Aug 3, 2010

I have heard that saving connection strings and stored procedure names in web.config file of our application is not safe. It is a good practice to store the connection string in a config file rather than as a hard coded string in our code and if we need to change it,then it makes our job easier. how to protect our code in web.config?

View 4 Replies

Web Forms :: Database Connections Not Closing?

Jan 19, 2011

I'm having some problems with connections to an SQL database not closing after being opened, which is maxxing out the pool and causing the site not to load any of the dynamic content (until eventually unused idle connections get close, as the problem seems to go away after a while).

I've been through my code several times and can't figure out where things are not being closed properly.

Is there a surefire way to make sure these connections are properly closed? Or to pinpoint where the problem lies?

Most places in the site I am using ObjectDataSource. You don't need to close a connection when using that, do you?

Where ObjectDataSource isn't used, a developer wrote this method and put it in a class file called "common.cs":

[Code]....

I searched the entire solution for every instance of "common.openDatabase()", and where it occurs I make sure there is a "cmd.Connection.Close();" that follows.

Am I missing something or doing it wrong?

Here's an example of where a db connection gets opened and then (purportedly) closed:

[Code]....

View 18 Replies

Web Forms :: Opening And Closing Readers And Connections?

Nov 18, 2010

I should be closing my readers and connections in a more robust way? Some of my questions are:

- If a try-catch block is used, should the closures be done in the Finally section? Or in the main Try section?

- Should all closures assess whether or not the control is already open before closing (to prevent error)? (see closure of conn below)

- Are there any other preferable ways of handling this? Trying to improve my code!

[Code]....

View 3 Replies

C# - How To Reuse A WMI Or DB Connections

Dec 12, 2010

I have simple asp.net web service, for monitoring and managing about 10 computers, with 4 webMethods and all of this methods are quite simple. In general they look sometning like: (1)make WMI connections to certain machine, (2)do some simple task, (3)return result.

Problem is that WMI connections to remote computers takes about 15s and I offten need to call 2 or 3 methods successively for the same machine.

From what I know, there is new instance of my service class (public class MonSvr :

System.Web.Services.WebService ) created every time webMethod is called.

So how can I share WMI or DB connection betwen all instances of my service that I could reuse this connection ? When there all multiple calls to webMethods of my service, does then each instance of web service runs in separate thread ?

View 2 Replies

Detect Non-closed Connections To SQL?

Apr 12, 2010

I've inherited a very large project in ASP.net, SQL 2005 and have found where some SQL connections are not closed - which is bad. Without going thru every line of code, is there a way to detect if connections are not being closed? Performance counter? as a follow up - how does SQL reclaim unclosed connections. I'm using non-pooled connectionstring.

View 2 Replies

Server Does Not Support Secure Connections

Mar 16, 2010

I get this error on line 39 -"Server does not support secure connections.".

[Code]....

View 5 Replies

Managing Concurrent Connections In IIS7?

Feb 8, 2011

I'm having an issue with my hosting provider (winhost.com). My app is built on ASP.NET 4 MVC 3. Up until a few days ago, everything was running fine. All of a sudden I've started getting 503 errors when trying to access my site (wikipediamaze.com). It doesn't happen all the time, just most of the time.

When someone starts playing the game a request is made to wikipedia.org to get the contents of the page for the current step in the puzzle. Basically I'm screen scraping wikipedia.org, injecting some html and then displaying the results. All of my web requests are closed immediately after receiving the data.

What winhost is telling me is that there are connections remaining open and causing any additional requests to the site to get the 503 Service Unavailable Error. What I can see from my end is that only 1 request is ever allowed to be made to wikipediamaze.com at a time. If you keep refreshing the page you'll eventually get the HTML but all subsequent requests (css,images,js) all get the 503 error. Even pages that don't ever call out to wikipedia.org.

If it was an issue with connection throttling in IIS, do both incoming and outgoing (requests made internally) fall in to the same bucket? If I'm sure all of my connections are being closed (and I've never had this issue before) what else could cause this?

View 1 Replies

SQL Server :: Connections Of External Mdf Files

Aug 12, 2010

I have a problem with the connection of external files - northwind.MDF Connection to SQL Server is fine.
But to connect to external files wrong. Error: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Intance Specified)

View 6 Replies

Increase Minimum Connections Pool To 100?

Jun 8, 2010

I have a website with high traffic.

Maybe I will increase minimum connections pool, to 100.

This is too high? Website have 10000 pageviews/day

View 2 Replies

Architecture :: Too Many Connections On Single Page?

May 21, 2010

My ISP manager complains that my pages open too many connections and it should be dealt with immidiatly.Now, i'm not sure what exactly he means.Most of my pages look something a like : Two drop-down-lists, one gridview, and few other controllers.now, MOST OF THESE CONTROLLERS POST BACK AND FETCH INFO FROM THE DATABASE.each of the eventhandler create a new connection instance, open a connection, fetch info, and than closes the onnection.Thing is that many users visit the site at (probably) the same time, so i was wondering how could I decrease the number of connections?Perhaps making sure that the connections do close immidiatly post command execution?

View 7 Replies

Is It Necessary To Open And Close Connections When Using SqlDataAdapter

Jan 28, 2013

Is this necessary to open and close connection when i am using SqlDataAdapter and DataSet to get data from  from table from  databse in sql server? Which one will be better to use in the following code. Code1 or Code2.

Code: 1 With open and colse connection

public DataSet GetFAcadSlidingImage()
{
SqlConnection con = GetConnection();
cmd = new SqlCommand("Pro_GetFAcadSlidingImage", con);
cmd.CommandType = CommandType.StoredProcedure;

[Code].....

Code:2 Without open and colse connection

public DataSet GetFAcadSlidingImage()
{
SqlConnection con = GetConnection();
cmd = new SqlCommand("Pro_GetFAcadSlidingImage", con);
cmd.CommandType = CommandType.StoredProcedure;

[Code].....

View 1 Replies

Web Forms :: Quotes In Xml Strings

Aug 26, 2010

I need to post an xml string to another website. I can't create an xml file, because some of the content is dynamically created. The two lines that are causing me problems are

sPostData = sPostData & "<?xml version='1.0'?>"
sPostData = sPostData & "<?qbmsxml version='4.1'?>"

The receiving site expects to see

<?xml version="1.0"?>
<?qbmsxml version="4.1"?>

not

<?xml version='1.0'?>
<?qbmsxml version='4.1'?>

The conversion from double quotes to single quotes isn't being accepted. So how can I send the string so that the versions are surrounded by double quotes?

View 1 Replies

DataSource Controls :: How To Detect Smo Remote Connections

Apr 19, 2010

I've been playing about for ages in an attempt to get a simple bit of code that can detect whether or not SQL Server is listening remotely or just locally.. My pretty lame attempt so far is as follows:

[Code]....

I'm sure there must be a better way to do this! Aside from the fact that this code fails to work properly.

sp.IPAddresses contains:

- 127.0.0.1
- 0.0.0.0
- 10.0.0.10

When I used Surface Area Manager > Surface Area Configuration for Services and Connections and set Remote Connections to "Local connections only" sp.IPAddresses still contains the same addresses.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved