473,787 Members | 2,971 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Referencing Connection Strings in web.config Problems

I am trying to copy a text file into a sql server database but I am
having problems with an undeclared variable error. The variable in
question is a reference to the connection string name in the web.config
file. Here is the connectionstrin g section of my web.config: There
are 2 strings, one called ConLocText and one called ConSQLLocal

*************** *************** ***********
<connectionStri ngs>
<add name="ConLocTex t" connectionStrin g="Driver={Micr osoft Text
Driver (*.txt;
*.csv)};default dir=C:\Inetpub\ wwwroot\Locatio nsUpload\FileUp loading\Locatio nCSV;driverid=2 7;extensions=No ne,asc,csv,tab, txt;fil=text;fi ledsn=C:\Progra m
Files\Common Files\ODBC\Data
Sources\Locatio nsTxtFile.dsn;m axbuffersize=20 48;maxscanrows= 25;pagetimeout= 5;safetransacti ons=0;threads=3 ;uid=admin;user commitsync=Yes"
providerName="S ystem.Data.Odbc " />
<add name="ConSQLLoc al" connectionStrin g="Data
Source=EBIZDEVA PP02;Initial Catalog=Atlas;P ersist Security
Info=True;User ID=username;Pas sword=password"
providerName="S ystem.Data.SqlC lient" />
</connectionStrin gs>
*************** *************** *************

Here is the start of my asp page; the last two lines are the one that
are reporting undeclared variables in visual studio:

*************** *************** *************** **********

Imports System.Data.Ole Db
Imports System.Data.Sql Client
Imports System.Configur ation
Imports System.Web.Conf iguration
Partial Class _Default
Inherits System.Web.UI.P age

Protected Sub btnUpload_Click (ByVal sender As Object, ByVal e As
System.EventArg s) _
Handles btnUpload.Click

Try

FileUpload1.Sav eAs(MapPath("~/LocationCSV/" & _
FileUpload1.Fil eName.ToString( )))

Dim connections As ConnectionStrin gSettingsCollec tion = _
ConfigurationMa nager.Connectio nStrings

Dim sourcecon As String =
connections(Con LocText).Connec tionString
Dim destcon As String =
connections(Con SQLLocal).Conne ctionString

*************** *************** *************** *******

Where and how do I declare these?

Nov 14 '06 #1
0 1053

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

Similar topics

6
2476
by: Mikey_Doc | last post by:
Hi We are running cms 2002, Framework 1.0 with Visual studio 2002. We have just upgraded to Framework 1.1 and visual studio 2003. All of our database connection strings are stored within the machine config, this was necessary as our web site has 4 environments and the database server has a different name in each. Since the upgrade the applications can't read the strings in the
14
3506
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, one developer suggested that it's a security flaw; therefore connection strings should be kept somewhere else or encrypted. My argument is that web.config file is protected by IIS and Windows security which is the case. And another argument is that...
4
5381
by: Matt Colegrove | last post by:
I'm working on a web app that is published to a hosting service. I'm developing it on my local PC with VS 2005 and SQL Express. The hosting service DB is SQL Server 2000. I have two connectionStrings defined in my web.config file, one for the development db and another for the production db. When I publish my app to the hosting site, I rename the two connection strings so that the production string will be the active string in the...
9
2776
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I have a question about storing the connection strings to the database in a config file or database. My manager wants me to store all the connection strings in a database, but I think it is easier and faster to store the connection strings in the config file. I was wondering if anyone has any opinion on this issue so that I can convince my manager. Thanks.
2
1769
by: Simon | last post by:
I have problems with connection strings. I have added new connection string to Web.config: <connectionStrings> <add name="ConnStr" connectionString="xxxxxxxxxxxxxxx"/> </connectionStrings> Bu when I want to access the data with: coll = ConfigurationManager.ConnectionStrings;
2
5397
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 ASP.NET applications that all manage connection strings in Web.config the same way, like this: This client has one Web.config file per application, and that one Web.config file is duplicated across all environments (i.e., dev machines, test,...
0
9655
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10169
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.