473,499 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Database connections in a code behind file.

Des
I am trying to connect to SQL Server. I have written some pages that
have got the line
Dim strConn as String = ConfigurationSettings.AppSettings("Thermos")
There is a valid line
<add key="Thermos" value="server=(local)\NetSDK; database=Thermos;
integrated security=true;" />

In web.config This is working fine. What I want to do is move some of
the code into a code behind file
Functions.vb. This is where things are going wrong. The following is
included in the Functions.vb file

Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Data
Imports System.Data.SqlClient
Imports System.DateTime

Public Class Functions : Inherits Page

But the line(s)
Dim strConn as String = ConfigurationSettings.AppSettings("Thermos")
Dim Adapter as new SqlDataAdapter(strItem,objConn)

As well as others are not recognized. Can this be achieved in a code
behind file

What I want out of my aspx file is

......
int = AddtoBasket(int ,int, int)
int = AddCustomer(char ,int, date) etc.

Feb 24 '06 #1
2 1307
Should be because you haven't imported the namespace. Use:
Imports System.Configuration

--
Rakesh Rajan

"Des" wrote:
I am trying to connect to SQL Server. I have written some pages that
have got the line
Dim strConn as String = ConfigurationSettings.AppSettings("Thermos")
There is a valid line
<add key="Thermos" value="server=(local)\NetSDK; database=Thermos;
integrated security=true;" />

In web.config This is working fine. What I want to do is move some of
the code into a code behind file
Functions.vb. This is where things are going wrong. The following is
included in the Functions.vb file

Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Data
Imports System.Data.SqlClient
Imports System.DateTime

Public Class Functions : Inherits Page

But the line(s)
Dim strConn as String = ConfigurationSettings.AppSettings("Thermos")
Dim Adapter as new SqlDataAdapter(strItem,objConn)

As well as others are not recognized. Can this be achieved in a code
behind file

What I want out of my aspx file is

......
int = AddtoBasket(int ,int, int)
int = AddCustomer(char ,int, date) etc.

Feb 24 '06 #2
Des
Thanks for that but now ir doesn't like Dim Adapter as new
SqlDataAdapter()

sqlProduct = "SELECT Name , Cost FROM Products WHERE ProductID = "
& ProdID
Dim Adapter as new SqlDataAdapter(strItem,objConn)
I have the esential inports

Imports System.Data
Imports System.Data.SqlClient

Feb 24 '06 #3

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

Similar topics

3
2395
by: Mudge | last post by:
Hi, My hosting provider only allows me to use 50 connections to my MySQL database that my Web site will use. I don't know what this 50 connections means exactly. Does this mean that only 50...
14
7113
by: L Mehl | last post by:
I tested a FE/BE application developed in A2000 on a A2002 machine and got this message when exiting the app. Clicking the only available button "OK", exits the application, as intended. The FE...
2
1874
by: Michael | last post by:
Hello, In my past ASP pages, at the top I used an include file to open an ado connection for the entire page, then at the bottom, I would have another include file to close the connection. ...
2
3482
by: Bryan | last post by:
Hello, I'm just starting to develop in asp.net and i have a question about using a database connection globally in my app. I have set up the procedures for getting all my connection string info...
4
4127
by: Nathaniel Sherman | last post by:
Alright, folks, here's the deal... I'm working on migrating a classic ASP website to an ASP.NET codebase. At the heart of the site is a MySQL database. To make sure an "in-process" program...
7
3946
by: wally | last post by:
I have Visual Studio 2005 Pro. I installed SQL Express 2005 and rebooted. But, when I right click on "Data Connections" in the Server Explorer and choose "Create New SQL Server Database..." and...
10
1676
by: rich | last post by:
I have a PHP5 application that accepts external messages, and inserts them into a database. It's rather high traffic.. the server could be receiving thousands at a time, and recently mysql has...
8
2815
by: BD | last post by:
I am developing C# win form app to work with remote database on SQL Server 2005. Problem scenario is as follows: 1. a form is open that has downloaded dataset to local cache 2. computer is...
9
6254
by: Gordon | last post by:
I want to add a feature to a project I'm working on where i have multiple users set up on my Postgres database with varying levels of access. At the bare minimum there will be a login user who...
0
7134
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
7014
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
7180
Oralloy
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,...
1
6905
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...
1
4921
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...
0
3108
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...
0
1429
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 ...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
311
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.