Please help with ASP.NET Database Connection

  • Thread starter Sparky Arbuckle
  • Start date
S

Sparky Arbuckle

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!
 
E

Elton Wang

Hi Sparky,

Try

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

HTH

Elton Wang
(e-mail address removed)


-----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
 
S

Sparky Arbuckle

Thanks for the prompt reply Elton! Now I get a new error message.
Apparently something is starting to work.

Error message - Could not find installable ISAM.
Error source - Microsoft JET Database Engine
 
S

Sparky Arbuckle

Error message - No value given for one or more required parameters.
Error source - Microsoft JET Database Engine

This is the new error. I am so confused!
 
E

Elton Wang

Try full path for the access database like
value="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\SomePath\Customers.mdb" in appSettings.

And grant Read/Write/Update permissions of the access file
to ASPNET account.

HTH

Elton Wang
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top