Database connections in a code behind file.

  • Thread starter Thread starter Des
  • Start date Start date
D

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.
 
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
 
Back
Top