473,321 Members | 1,916 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,321 software developers and data experts.

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 connectionstring section of my web.config: There
are 2 strings, one called ConLocText and one called ConSQLLocal

*****************************************
<connectionStrings>
<add name="ConLocText" connectionString="Driver={Microsoft Text
Driver (*.txt;
*.csv)};defaultdir=C:\Inetpub\wwwroot\LocationsUpl oad\FileUploading\LocationCSV;driverid=27;extensio ns=None,asc,csv,tab,txt;fil=text;filedsn=C:\Progra m
Files\Common Files\ODBC\Data
Sources\LocationsTxtFile.dsn;maxbuffersize=2048;ma xscanrows=25;pagetimeout=5;safetransactions=0;thre ads=3;uid=admin;usercommitsync=Yes"
providerName="System.Data.Odbc" />
<add name="ConSQLLocal" connectionString="Data
Source=EBIZDEVAPP02;Initial Catalog=Atlas;Persist Security
Info=True;User ID=username;Password=password"
providerName="System.Data.SqlClient" />
</connectionStrings>
*******************************************

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.OleDb
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Web.Configuration
Partial Class _Default
Inherits System.Web.UI.Page

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

Try

FileUpload1.SaveAs(MapPath("~/LocationCSV/" & _
FileUpload1.FileName.ToString()))

Dim connections As ConnectionStringSettingsCollection = _
ConfigurationManager.ConnectionStrings

Dim sourcecon As String =
connections(ConLocText).ConnectionString
Dim destcon As String =
connections(ConSQLLocal).ConnectionString

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

Where and how do I declare these?

Nov 14 '06 #1
0 1035

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

Similar topics

6
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...
14
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,...
4
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...
9
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...
2
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> ...
2
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.