By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,671 Members | 1,670 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,671 IT Pros & Developers. It's quick & easy.

Could not load type System.Web.UI.WebControls.AccessDataSource fromassembly System.Web, Version=1.0.5000.0

P: n/a
DC
Why would this code give me the error

"Could not load type System.Web.UI.WebControls.AccessDataSource from
assembly System.Web, Version=1.0.5000.0" at line 16...

<form id="form1" runat="server">
Line 15: <div>
Line 16: <asp:AccessDataSource ID="AccessDataSource1"
Runat="server" DataFile="data\pubs.mdb"
Line 17: SelectCommand="select * from [authors]"
Line 18: DeleteCommand="DELETE FROM [authors] WHERE [au_id] = ?"

I heard it might be because .net framework 2.0 is not installed
properly, so I reinstalled .net 2.0 from scratch (its on a winsows 2003
server) but to no avail.

Any idea what is going on here?
<%@ Page language="C#" %>

<%@ import namespace="System" %>
<%@ import namespace="System.Web" %>
<%@ import namespace="System.Web.UI" %>
<%@ import namespace="System.Web.UI.HtmlControls" %>
<%@ import namespace="System.Web.UI.WebControls" %>
<%@ import namespace="System.Data" %>
<%@ import namespace="System.Data.OleDb" %>

<script RunAt="server">

void EmployeesGridView_OnSelectedIndexChanged(Object sender, EventArgs e)
{
EmployeeDetailsSqlDataSource.SelectParameters["EmpID"].DefaultValue =
EmployeesGridView.SelectedValue.ToString();
EmployeeFormView.DataBind();
}

void EmployeeFormView_ItemUpdated(Object sender,
FormViewUpdatedEventArgs e)
{
EmployeesGridView.DataBind();
}

void EmployeeFormView_ItemDeleted(Object sender,
FormViewDeletedEventArgs e)
{
EmployeesGridView.DataBind();
}

void EmployeeDetailsSqlDataSource_OnInserted(Object sender,
SqlDataSourceStatusEventArgs e)
{
System.Data.Common.DbCommand command = e.Command;

EmployeeDetailsSqlDataSource.SelectParameters["EmpID"].DefaultValue =
command.Parameters["@EmpID"].Value.ToString();

EmployeesGridView.DataBind();
EmployeeFormView.DataBind();
}

</script>

<html>
<body>
<form RunAt="server">

<h3>FormView Example</h3>

<table cellspacing="10">

<tr>
<td>
<asp:GridView ID="EmployeesGridView"
DataSourceID="EmployeeAccessDataSource"
AutoGenerateColumns="false"
DataKeyNames="EmployeeID"

OnSelectedIndexChanged="EmployeesGridView_OnSelect edIndexChanged"
RunAt="Server">

<HeaderStyle backcolor="Navy"
forecolor="White" />

<Columns>

<asp:ButtonField Text="Details..."
HeaderText="Show<BR>Details"
CommandName="Select"/>

<asp:BoundField DataField="EmployeeID"
HeaderText="Employee ID"/>
<asp:BoundField DataField="LastName"
HeaderText="Last Name"/>
<asp:BoundField DataField="FirstName"
HeaderText="First Name"/>

</Columns>

</asp:GridView>

</td>

<td valign="top">

<asp:FormView ID="EmployeeFormView"
DataSourceID="EmployeeDetailsSqlDataSource"
DataKeyNames="EmployeeID"
Gridlines="Both"
OnItemUpdated="EmployeeFormView_ItemUpdated"
OnItemDeleted="EmployeeFormView_ItemDeleted"
RunAt="server">

<HeaderStyle backcolor="Navy"
forecolor="White"/>

<RowStyle backcolor="White"/>

<EditRowStyle backcolor="LightCyan"/>

<ItemTemplate>
<table>
<tr><td align=right><B>Employee ID:</B></td><td><%#
Eval("EmployeeID") %></td></tr>
<tr><td align=right><B>First Name:</B></td<td><%#
Eval("FirstName") %></td></tr>
<tr><td align=right><B>Last Name:</B></td <td><%#
Eval("LastName") %></td></tr>
<tr>
<td colspan="2">
<asp:LinkButton ID="EditButton"
Text="Edit"
CommandName="Edit"
RunAt="server"/>
&nbsp;
<asp:LinkButton ID="NewButton"
Text="New"
CommandName="New"
RunAt="server"/>
&nbsp;
<asp:LinkButton ID="DeleteButton"
Text="Delete"
CommandName="Delete"
RunAt="server"/>
</td>
</tr>
</table>
</ItemTemplate>

<EditItemTemplate>
<table>
<tr><td align=right><B>Employee ID:</B></td><td><%#
Eval("EmployeeID") %></td></tr>

<tr><td align=right><B>First Name:</B></td>
<td><asp:TextBox ID="EditFirstNameTextBox"
Text='<%# Bind("FirstName") %>'
RunAt="Server" /></td></tr>

<tr><td align=right><B>Last Name:</B></td>
<td><asp:TextBox ID="EditLastNameTextBox"
Text='<%# Bind("LastName") %>'
RunAt="Server" /></td></tr>
<tr>
<td colspan="2">
<asp:LinkButton ID="UpdateButton"
Text="Update"
CommandName="Update"
RunAt="server"/>
&nbsp;
<asp:LinkButton ID="CancelUpdateButton"
Text="Cancel"
CommandName="Cancel"
RunAt="server"/>
</td>
</tr>
</table>
</EditItemTemplate>

<InsertItemTemplate>
<table>
<tr><td align=right><B>First Name:</B></td>
<td><asp:TextBox ID="InsertFirstNameTextBox"
Text='<%# Bind("FirstName") %>'
RunAt="Server" /></td></tr>

<tr><td align=right><B>Last Name:</B></td>
<td><asp:TextBox ID="InsertLastNameTextBox"
Text='<%# Bind("LastName") %>'
RunAt="Server" /></td></tr>

<tr>
<td colspan="2">
<asp:LinkButton ID="InsertButton"
Text="Insert"
CommandName="Insert"
RunAt="server"/>
&nbsp;
<asp:LinkButton ID="CancelInsertButton"
Text="Cancel"
CommandName="Cancel"
RunAt="server"/>
</td>
</tr>
</table>
</InsertItemTemplate>

</asp:FormView>

</td>

</tr>

</table>

<asp:AccessDataSource
id="EmployeeAccessDataSource"
DataFile="~/App_Data/Northwind.mdb"
runat="server"
SelectCommand="SELECT EmployeeID, LastName, FirstName FROM
Employees WHERE EmployeeID = @EmpID"

InsertCommand="INSERT INTO Employees(LastName, FirstName)
VALUES (@LastName, @FirstName);
SELECT @EmpID = SCOPE_IDENTITY()"
UpdateCommand="UPDATE Employees SET LastName=@LastName,
FirstName=@FirstName
WHERE EmployeeID=@EmployeeID"
DeleteCommand="DELETE Employees WHERE EmployeeID=@EmployeeID"

ConnectionString="<%$ ConnectionStrings:NorthwindConnection %>"
OnInserted="EmployeeDetailsSqlDataSource_OnInserte d"
connectionstring="<%$ ConnectionStrings:NorthwindConnection %>"

<SelectParameters>
<asp:Parameter Name="Beginning Date" Type="DateTime"
defaultValue="1/1/1997" />
<asp:Parameter Name="Ending Date" Type="DateTime"
defaultValue="1/31/1997" />
</SelectParameters>
</asp:AccessDataSource>
<SelectParameters>
<asp:Parameter Name="EmpID" Type="Int32" DefaultValue="0" />
</SelectParameters>

<InsertParameters>
<asp:Parameter Name="EmpID" Direction="Output" Type="Int32"
DefaultValue="0" />
</InsertParameters>

</asp:AccessDataSource>

</form>
</body>
--
_______________________________________________

DC

"You can not reason a man out of a position he did not reach through reason"

"Don't use a big word where a diminutive one will suffice."

"A man with a watch knows what time it is. A man with two watches is
never sure." Segal's Law
Jul 3 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.