Please help with ASP.NET Database Connection
From: Elton Wang (anonymous_at_discussions.microsoft.com)
Date: 02/06/05
- Next message: Sparky Arbuckle: "Re: Please help with ASP.NET Database Connection"
- Previous message: Sparky Arbuckle: "Please help with ASP.NET Database Connection"
- In reply to: Sparky Arbuckle: "Please help with ASP.NET Database Connection"
- Next in thread: Sparky Arbuckle: "Re: Please help with ASP.NET Database Connection"
- Reply: Sparky Arbuckle: "Re: Please help with ASP.NET Database Connection"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 6 Feb 2005 13:10:47 -0800
Hi Sparky,
Try
Dim myConnection as NEW
OLEDBConnection(ConfigurationSettings.AppSettings
("myConnection"))
HTH
Elton Wang
elton_wang@hotmail.com
>-----Original Message-----
>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!
>
>.
>
- Next message: Sparky Arbuckle: "Re: Please help with ASP.NET Database Connection"
- Previous message: Sparky Arbuckle: "Please help with ASP.NET Database Connection"
- In reply to: Sparky Arbuckle: "Please help with ASP.NET Database Connection"
- Next in thread: Sparky Arbuckle: "Re: Please help with ASP.NET Database Connection"
- Reply: Sparky Arbuckle: "Re: Please help with ASP.NET Database Connection"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|