Hi, I am working on a class assignment, and I am receiving an error, that has me stumped. In the assignment I am trying to bind a datagrid control to an Access Database. When I compile the Web Application I get the following error: - c:\inetpub\wwwroot\Chapter7\DataGridDisplay.aspx.cs(32): The type or namespace name 'OleDbDataAdapter1' could not be found (are you missing a using directive or an assembly reference?)
I have the OleDbDataAdapter declared - protected System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1;
So does anyone have any idea what could be causing the compiler to kick out this error? Is there a piece of code that I must be missing somewhere?
I am going to include the Code Behind the page code and the asp.net html code in two posts immediately following this one. Any help that could be provided would be greatly appreciated.
2 1873
ASP.NET html code: - <%@ Page Language="c#" AutoEventWireup="false" Codebehind="DataGridDisplay.aspx.cs" Inherits="Chapter7.DataGridDisplay" %>
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
<HTML>
-
<HEAD>
-
<title></title>
-
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
-
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
-
<meta name="vs_defaultClientScript" content="JavaScript">
-
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
-
</HEAD>
-
<body MS_POSITIONING="GridLayout">
-
<form id="Form1" method="post" runat="server">
-
<asp:DataGrid id="MyDG" style="Z-INDEX: 101; LEFT: 30px; POSITION: absolute; TOP: 107px" runat="server" DataSource="<%# dataView1 %>" AutoGenerateColumns="False">
-
</asp:DataGrid>
-
<asp:Label id="Label1" style="Z-INDEX: 105; LEFT: 143px; POSITION: absolute; TOP: 54px" runat="server"
-
ForeColor="DarkSlateGray" Font-Size="Medium" Font-Names="Trebuchet MS"> Binding an Access Database to a DataGrid Control</asp:Label><IMG style="Z-INDEX: 103; LEFT: 6px; POSITION: absolute; TOP: 3px" src="images/header2.jpg">
-
</form>
-
</body>
-
</HTML>
-
C# code behind the page: - using System;
-
using System.Collections;
-
using System.ComponentModel;
-
using System.Data;
-
using System.Drawing;
-
using System.Web;
-
using System.Web.SessionState;
-
using System.Web.UI;
-
using System.Web.UI.WebControls;
-
using System.Web.UI.HtmlControls;
-
-
namespace Chapter7
-
{
-
/// <summary>
-
/// Summary description for DataGridDisplay.
-
/// </summary>
-
public class DataGridDisplay : System.Web.UI.Page
-
{
-
protected System.Web.UI.WebControls.DataGrid MyDG;
-
protected System.Web.UI.WebControls.Label Label1;
-
protected System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1;
-
protected System.Data.OleDb.OleDbCommand oleDbSelectCommand1;
-
protected System.Data.OleDb.OleDbCommand oleDbInsertCommand1;
-
protected System.Data.OleDb.OleDbCommand oleDbUpdateCommand1;
-
protected System.Data.OleDb.OleDbCommand oleDbDeleteCommand1;
-
protected Chapter7.MyDS myDS1;
-
protected System.Data.DataView dataView1;
-
protected System.Data.OleDb.OleDbConnection oleDbConnection1;
-
-
private void Page_Load(object sender, System.EventArgs e)
-
{
-
OleDbDataAdapter1.Fill(myDS1);
-
Page.DataBind();
-
// Put user code to initialize the page here
-
}
-
-
#region Web Form Designer generated code
-
override protected void OnInit(EventArgs e)
-
{
-
//
-
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
-
//
-
InitializeComponent();
-
base.OnInit(e);
-
}
-
-
/// <summary>
-
/// Required method for Designer support - do not modify
-
/// the contents of this method with the code editor.
-
/// </summary>
-
private void InitializeComponent()
-
{
-
this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();
-
this.oleDbDeleteCommand1 = new System.Data.OleDb.OleDbCommand();
-
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
-
this.oleDbInsertCommand1 = new System.Data.OleDb.OleDbCommand();
-
this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
-
this.oleDbUpdateCommand1 = new System.Data.OleDb.OleDbCommand();
-
this.myDS1 = new Chapter7.MyDS();
-
this.dataView1 = new System.Data.DataView();
-
((System.ComponentModel.ISupportInitialize)(this.myDS1)).BeginInit();
-
((System.ComponentModel.ISupportInitialize)(this.dataView1)).BeginInit();
-
//
-
// oleDbDataAdapter1
-
//
-
this.oleDbDataAdapter1.DeleteCommand = this.oleDbDeleteCommand1;
-
this.oleDbDataAdapter1.InsertCommand = this.oleDbInsertCommand1;
-
this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;
-
this.oleDbDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
-
new System.Data.Common.DataTableMapping("Table", "Products", new System.Data.Common.DataColumnMapping[] {
-
new System.Data.Common.DataColumnMapping("ModelName", "ModelName"),
-
new System.Data.Common.DataColumnMapping("ProductID", "ProductID"),
-
new System.Data.Common.DataColumnMapping("UnitCost", "UnitCost")})});
-
this.oleDbDataAdapter1.UpdateCommand = this.oleDbUpdateCommand1;
-
//
-
// oleDbDeleteCommand1
-
//
-
this.oleDbDeleteCommand1.CommandText = "DELETE FROM Products WHERE (ProductID = ?) AND (ModelName = ? OR ? IS NULL AND Mo" +
-
"delName IS NULL) AND (UnitCost = ?)";
-
this.oleDbDeleteCommand1.Connection = this.oleDbConnection1;
-
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ProductID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ProductID", System.Data.DataRowVersion.Original, null));
-
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ModelName", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ModelName", System.Data.DataRowVersion.Original, null));
-
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ModelName1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ModelName", System.Data.DataRowVersion.Original, null));
-
this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_UnitCost", System.Data.OleDb.OleDbType.Currency, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "UnitCost", System.Data.DataRowVersion.Original, null));
-
//
-
// oleDbConnection1
-
//
-
this.oleDbConnection1.ConnectionString = @"Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Database Password=;Data Source=""C:\Inetpub\wwwroot\Chapter7\data\TaraStore.mdb"";Password=;Jet OLEDB:Engine Type=5;Jet OLEDB:Global Bulk Transactions=1;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False";
-
//
-
// oleDbInsertCommand1
-
//
-
this.oleDbInsertCommand1.CommandText = "INSERT INTO Products(ModelName, ProductID, UnitCost) VALUES (?, ?, ?)";
-
this.oleDbInsertCommand1.Connection = this.oleDbConnection1;
-
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("ModelName", System.Data.OleDb.OleDbType.VarWChar, 50, "ModelName"));
-
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("ProductID", System.Data.OleDb.OleDbType.Integer, 0, "ProductID"));
-
this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("UnitCost", System.Data.OleDb.OleDbType.Currency, 0, "UnitCost"));
-
//
-
// oleDbSelectCommand1
-
//
-
this.oleDbSelectCommand1.CommandText = "SELECT ModelName, ProductID, UnitCost FROM Products WHERE (SubCategoryID = 2)";
-
this.oleDbSelectCommand1.Connection = this.oleDbConnection1;
-
//
-
// oleDbUpdateCommand1
-
//
-
this.oleDbUpdateCommand1.CommandText = "UPDATE Products SET ModelName = ?, ProductID = ?, UnitCost = ? WHERE (ProductID =" +
-
" ?) AND (ModelName = ? OR ? IS NULL AND ModelName IS NULL) AND (UnitCost = ?)";
-
this.oleDbUpdateCommand1.Connection = this.oleDbConnection1;
-
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("ModelName", System.Data.OleDb.OleDbType.VarWChar, 50, "ModelName"));
-
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("ProductID", System.Data.OleDb.OleDbType.Integer, 0, "ProductID"));
-
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("UnitCost", System.Data.OleDb.OleDbType.Currency, 0, "UnitCost"));
-
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ProductID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ProductID", System.Data.DataRowVersion.Original, null));
-
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ModelName", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ModelName", System.Data.DataRowVersion.Original, null));
-
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ModelName1", System.Data.OleDb.OleDbType.VarWChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "ModelName", System.Data.DataRowVersion.Original, null));
-
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_UnitCost", System.Data.OleDb.OleDbType.Currency, 0, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "UnitCost", System.Data.DataRowVersion.Original, null));
-
//
-
// myDS1
-
//
-
this.myDS1.DataSetName = "myDS";
-
this.myDS1.Locale = new System.Globalization.CultureInfo("en-US");
-
this.Load += new System.EventHandler(this.Page_Load);
-
((System.ComponentModel.ISupportInitialize)(this.myDS1)).EndInit();
-
((System.ComponentModel.ISupportInitialize)(this.dataView1)).EndInit();
-
-
}
-
#endregion
-
-
-
}
-
}
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Thomas Connolly |
last post by:
I have 2 pages referencing the same codebehind file in my
project. Originally the pages referenced separate code
behind files. Once I changed the reference to the same
file, everything worked...
|
by: ani |
last post by:
When I try to open the web form page, I get a designer
error which says:
'the file could not be loaded into the web forms designer.
Please correct the following error and then try loading it...
|
by: Nehal Shah |
last post by:
I've read that in the Page Directive of an aspx page, changing the
CodeBehind attribute to Src saves you from having to compile the page before
refreshing. This is preferable in a large...
|
by: A.M |
last post by:
Hi,
Using VS.NET 2003, If i use SRC page attribute instead of CodeBehind, do i
still have intelisence and generally IDE support for that?
Thanks,
Ali
|
by: Wardeaux |
last post by:
All,
Wanting to find a way to create web pages to add to my website without
having to recompile the codebehind everytime I want to add a new one...
Here's the deal:
I have a web app that takes...
|
by: Jack |
last post by:
Hello,
What is the difference between SRC and CODEBEHIND Tags?
Example
<%@ Page Language="vb" ValidateRequest="false" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb" %>
or
|
by: N. Demos |
last post by:
I have a user control with code behind of which two instances are
created/declared in my aspx page. The aspx page has code behind also, as
I need to access methods of the usercontrols on page...
|
by: Plamen Doykov |
last post by:
Hi all
I have converted a simple project from ASP.NET 1 to 2.0 with the latest
prerelease of Visual Studio 2005. The problem is I can't access internal
members from the code behind. It gives:...
|
by: Mr Newbie |
last post by:
I am messing around with Web User Controls at present and (think) I have
discovered the following.
1.) The identifier for the control in the code behind must match the ID for
the control on the...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
| |