Hello Morris,
You need to add include the directives
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
in your test.aspx file. It is not necessary to add the above into the
master page if the master page itself does not use OleDbDataAdapater.
To help you better understand why we need to add the imports in the
test.aspx file, please have a look at this example:
Suppose that we have a C# Dll project. In the project, we have Container.cs
that defines a class "Container", and Component.cs that defines a class
"Component".
In Container, it stores a component:
class Container
{
Component component = new Component();
}
In Component, it has a method that reads data from a spreadsheet with OLEDB:
class Component
{
public void ProcessData()
{
string conn = ("Provider=Microsoft.Jet.OLEDB.4.0;" +
("Data Source=C:\\Program Files\\CALLMaster\\Data\\test.xls;" +
// or use instead of Excel 8.0 - Excel 5.0
"Extended Properties=\"Excel 8.0;\""));
string SSQL = "SELECT name , dept, salary from [sheet1$]";
// here use oleDataReader
OleDbDataAdapter oleDA = new OleDbDataAdapter(SSQL, conn);
DataSet ds = new DataSet();
//oleDA.TableMappings.Add("Table","ExcelTest"); // Require
oleDA.Fill(ds);
}
}
In this example, if we add
using System.Data.OleDb;
using System.Data;
only to Container.cs, we will get several compilation errors saying that
OleDbDataAdapter could not be found, (are you missing a using directive or
an assembly reference?) as you saw.
However, as long as we add
using System.Data.OleDb;
using System.Data;
to Component.cs, the error is fixed.
This Container.cs - Component.cs example is just like the Masterpage.master
- test.aspx relationship in this case. Importing the namespaces solely in
the master page does not "inherit" to the component pages (test.aspx),
thus, we need to import the namespaces in the component pages.
Any more clear? I hope that I'm not confusing you more.
Regards,
Jialiang Ge (
[email protected], remove 'online.')
Microsoft Online Community Support
=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================