Need Help with Database Connection w/ ASP.NET!

From: Sparky Arbuckle (twa_at_secureroot.com)
Date: 02/06/05


Date: 6 Feb 2005 12:57:50 -0800

web.config

<?xml version="1.0" encoding="utf-8" ?>

<configuration>
<!-- application specific settings -->

<appSettings>
<add key="myConnection" value="Provider=Microsoft.Jet.OLEDB.4.0;Data
source=Customers.mdb;" />
</appSettings>

<system.web>
<httpRuntime executionTimeout="5" maxRequestLength="8192"/>
<customErrors mode="Off"/>
<compilation debug="true"/>
</system.web>

</configuration>
--------------------------------------------------------

DataGridEmail.aspx (Connection String)

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<SCRIPT runat="SERVER">

'Modified from Payne Listings 10.10 & 10.11
'declare connection object with page-level scope (use in two
subroutines)

Dim myConnection as NEW
OLEDBConnection(ConfigurationSettings.AppSettings("Customers"))

Sub Page_Load(obj as Object, e as EventArgs)
IF NOT Page.IsPostBack then subFillDataGrid()
END Sub

Sub subFillDataGrid(Optional EditIndex as integer=-1)
'If Datagrid is in edit mode then specify row to edit
IF NOT EditIndex.Equals(Nothing) then dgData.EditItemIndex = EditIndex

'Initialize command object
Dim objCommand as new OleDbCommand ("SELECT CustID, FirstName,
LastName, Email", myConnection)

TRY
myConnection.Open()
dgData.DataSource =
objCommand.ExecuteReader(CommandBehavior.CloseConnection)
dgData.DataBind()
CATCH objError as Exception
      lblMessage.text += "<br />FillDataGrid "
      lblMessage.text += "<br />Error message - " & objError.Message
      lblMessage.text += "<br />Error source - " & objError.Source
END TRY

END Sub
--------------------------------------------

My error is as follows:

Error message - The ConnectionString property has not been initialized.
Error source - System.Data

Any help would be greatly appreciated!



Relevant Pages

  • ADO Connection Object
    ... I would like a function to test whether I can open a connection to my SQL ... Server database. ... Dim WithEvents m_cnn As ADODB.Connection ... Private Sub Form_Open ...
    (comp.databases.ms-access)
  • Re: Threading.Monitor.Enter that doesnt /quite/ block the thread
    ... Protected Overloads Overrides Sub Dispose ... Public ReadOnly Property Connection() As SqlCeConnection ... Private Sub Form1_Activated(ByVal sender As Object, ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Threading.Monitor.Enter that doesnt /quite/ block the thread
    ... Protected Overloads Overrides Sub Dispose ... Public ReadOnly Property Connection() As SqlCeConnection ... Private Sub Form1_Activated(ByVal sender As Object, ...
    (microsoft.public.dotnet.framework.compactframework)
  • Please help with ASP.NET Database Connection
    ... DataGridEmail.aspx (Connection String) ... Sub Page_Load ... 'If Datagrid is in edit mode then specify row to edit ... 'Initialize command object ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: strange slowness with getrows method
    ... > After creating the recordset objRS (not actually listed on code I ... Create a connection variable and open it at the beginning of your page: ... SUB DataGetrows(parmConn, parmSQL, byref parmArray, byref parmDict) ...
    (microsoft.public.inetserver.asp.db)

Loading