Anyone help with this? i have tried lots of ways to query this database and create the insert command, including making my own data sets and setting it up that way with my own custom SQL statement.....this did not work, so i though i would use VWD 2008's own tools to create the insert, i have been left with the following error:
The DataSourceID of 'DetailsView1' must be the ID of a control of type IDataSource. A control with ID 'AccessDataSource1' could not be found.
Everything looks ok to me. Code below:
<%
@ Page Title="" Language="C#" MasterPageFile="~/Helpdesk/HelpdeskMaster.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Helpdesk_Default2" %><
asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <form id="form1" runat="server"><asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" CellPadding="4" DataSourceID="AccessDataSource1" ForeColor="#333333" GridLines="None" Height="50px" style="font-family: Arial" Width="309px"> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" /> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" /> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> <Fields><asp:BoundField DataField="First_Name" HeaderText="First_Name" SortExpression="First_Name" /><asp:BoundField DataField="Middle_Name" HeaderText="Middle_Name" SortExpression="Middle_Name" /><asp:BoundField DataField="Surname" HeaderText="Surname" SortExpression="Surname" /><asp:BoundField DataField="Location" HeaderText="Location" SortExpression="Location" /><asp:BoundField DataField="Job_Role" HeaderText="Job_Role" SortExpression="Job_Role" /><asp:BoundField DataField="Line_Manager" HeaderText="Line_Manager" SortExpression="Line_Manager" /><asp:CheckBoxField DataField="Desktop_user?" HeaderText="Desktop_user?" SortExpression="Desktop_user?" /><asp:CheckBoxField DataField="Laptop_User?" HeaderText="Laptop_User?" SortExpression="Laptop_User?" /><asp:BoundField DataField="W_drive_folders?" HeaderText="W_drive_folders?" SortExpression="W_drive_folders?" /><asp:BoundField DataField="Using_specific_software?" HeaderText="Using_specific_software?" SortExpression="Using_specific_software?" /> <asp:CommandField ShowInsertButton="True" /> </Fields> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#999999" /> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> </asp:DetailsView></form></
asp:Content>
![]() |
0 |
![]() |
Have you included an <asp:AccessDataSource> control in your .aspx file?
You need sth like this:
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataSourceMode="DataSet" DataFile="~/App_Data/Northwind.mdb" SelectCommand="SELECT EmployeeID,FirstName,LastName,Title FROM Employees" UpdateCommand="Update Employees SET FirstName=?,LastName=?,Title=? WHERE EmployeeID=@EmployeeID"> </asp:AccessDataSource>
For detailed information on Access Data Sources you can have a look here:http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.accessdatasource.aspx
Much ado about nothing
![]() |
0 |
![]() |
Hi thanks for reply. That code did already exist. However i now get a different error on another attempt i had made.
<%
@ Page Title="" Language="C#" MasterPageFile="~/Helpdesk/HelpdeskMaster.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Helpdesk_Default" %><
asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <form id="form1" runat="server"> <p><asp:AccessDataSource ID="AccessDataSource1" runat="server" ConflictDetection="CompareAllValues" DataFile="~/newaccounts.mdb" DeleteCommand="DELETE FROM [newaccounts] WHERE [Request ID] = ? AND (([First Name] = ?) OR ([First Name] IS NULL AND ? IS NULL)) AND (([Middle Name] = ?) OR ([Middle Name] IS NULL AND ? IS NULL)) AND (([Surname] = ?) OR ([Surname] IS NULL AND ? IS NULL)) AND (([Location] = ?) OR ([Location] IS NULL AND ? IS NULL)) AND (([Job Role] = ?) OR ([Job Role] IS NULL AND ? IS NULL)) AND (([Line Manager] = ?) OR ([Line Manager] IS NULL AND ? IS NULL)) AND [Desktop user?] = ? AND [Laptop User?] = ? AND (([W drive folders?] = ?) OR ([W drive folders?] IS NULL AND ? IS NULL)) AND (([Using specific software?] = ?) OR ([Using specific software?] IS NULL AND ? IS NULL))" InsertCommand="INSERT INTO [newaccounts] (([First_Name], [Middle_Name], [Surname], [Location], [Job_Role], [Line_Manager], [Desktop_user?], [Laptop_User?], [W_drive_folders?], [Using_specific_software?]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" SelectCommand="SELECT * FROM [newaccounts]"UpdateCommand="UPDATE [newaccounts] SET [First Name] = ?, [Middle Name] = ?, [Surname] = ?, [Location] = ?, [Job Role] = ?, [Line Manager] = ?, [Desktop user?] = ?, [Laptop User?] = ?, [W drive folders?] = ?, [Using specific software?] = ? WHERE [Request ID] = ? AND (([First Name] = ?) OR ([First Name] IS NULL AND ? IS NULL)) AND (([Middle Name] = ?) OR ([Middle Name] IS NULL AND ? IS NULL)) AND (([Surname] = ?) OR ([Surname] IS NULL AND ? IS NULL)) AND (([Location] = ?) OR ([Location] IS NULL AND ? IS NULL)) AND (([Job Role] = ?) OR ([Job Role] IS NULL AND ? IS NULL)) AND (([Line Manager] = ?) OR ([Line Manager] IS NULL AND ? IS NULL)) AND [Desktop user?] = ? AND [Laptop User?] = ? AND (([W drive folders?] = ?) OR ([W drive folders?] IS NULL AND ? IS NULL)) AND (([Using specific software?] = ?) OR ([Using specific software?] IS NULL AND ? IS NULL))"> <DeleteParameters> <asp:Parameter Name="original_Request_ID" Type="Int32" /> <asp:Parameter Name="original_First_Name" Type="String" /> <asp:Parameter Name="original_Middle_Name" Type="String" /> <asp:Parameter Name="original_Surname" Type="String" /> <asp:Parameter Name="original_Location" Type="String" /> <asp:Parameter Name="original_Job_Role" Type="String" /> <asp:Parameter Name="original_Line_Manager" Type="String" /> <asp:Parameter Name="original_column1" Type="Boolean" /> <asp:Parameter Name="original_column2" Type="Boolean" /> <asp:Parameter Name="original_column3" Type="String" /> <asp:Parameter Name="original_column4" Type="String" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="First_Name" Type="String" /> <asp:Parameter Name="Middle_Name" Type="String" /> <asp:Parameter Name="Surname" Type="String" /> <asp:Parameter Name="Location" Type="String" /> <asp:Parameter Name="Job_Role" Type="String" /> <asp:Parameter Name="Line_Manager" Type="String" /> <asp:Parameter Name="column1" Type="Boolean" /> <asp:Parameter Name="column2" Type="Boolean" /> <asp:Parameter Name="column3" Type="String" /> <asp:Parameter Name="column4" Type="String" /> <asp:Parameter Name="original_Request_ID" Type="Int32" /> <asp:Parameter Name="original_First_Name" Type="String" /> <asp:Parameter Name="original_Middle_Name" Type="String" /> <asp:Parameter Name="original_Surname" Type="String" /> <asp:Parameter Name="original_Location" Type="String" /> <asp:Parameter Name="original_Job_Role" Type="String" /> <asp:Parameter Name="original_Line_Manager" Type="String" /> <asp:Parameter Name="original_column1" Type="Boolean" /> <asp:Parameter Name="original_column2" Type="Boolean" /> <asp:Parameter Name="original_column3" Type="String" /> <asp:Parameter Name="original_column4" Type="String" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="Request_ID" Type="Int32" /> <asp:Parameter Name="First_Name" Type="String" /> <asp:Parameter Name="Middle_Name" Type="String" /> <asp:Parameter Name="Surname" Type="String" /> <asp:Parameter Name="Location" Type="String" /> <asp:Parameter Name="Job_Role" Type="String" /> <asp:Parameter Name="Line_Manager" Type="String" /> <asp:Parameter Name="Desktop_user?" Type="Boolean" /> <asp:Parameter Name="Laptop_User?" Type="Boolean" /> <asp:Parameter Name="W_drive_folders?" Type="String" /> <asp:Parameter Name="Using_specific_software?" Type="String" /> </InsertParameters> </asp:AccessDataSource> </p> <p><asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" CellPadding="4" DataKeyNames="Request_ID" DataSourceID="AccessDataSource1" ForeColor="#333333" GridLines="None" Height="50px" style="font-family: Arial" Width="441px"> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" /> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" /> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> <Fields><asp:BoundField DataField="Request_ID" HeaderText="Request_ID" InsertVisible="False" ReadOnly="True" SortExpression="Request_ID" /><asp:BoundField DataField="First_Name" HeaderText="First_Name" SortExpression="First_Name" /><asp:BoundField DataField="Middle_Name" HeaderText="Middle_Name" SortExpression="Middle_Name" /><asp:BoundField DataField="Surname" HeaderText="Surname" SortExpression="Surname" /><asp:BoundField DataField="Location" HeaderText="Location" SortExpression="Location" /><asp:BoundField DataField="Job_Role" HeaderText="Job_Role" SortExpression="Job_Role" /><asp:BoundField DataField="Line_Manager" HeaderText="Line_Manager" SortExpression="Line_Manager" /><asp:CheckBoxField DataField="Desktop_user?" HeaderText="Desktop_user?" SortExpression="Desktop_user?" /><asp:CheckBoxField DataField="Laptop_User?" HeaderText="Laptop_User?" SortExpression="Laptop_User?" /><asp:BoundField DataField="W_drive_folders?" HeaderText="W_drive_folders?" SortExpression="W_drive_folders?" /><asp:BoundField DataField="Using_specific_software?" HeaderText="Using_specific_software?" SortExpression="Using_specific_software?" /> <asp:CommandField ShowInsertButton="True" /> </Fields> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#999999" /> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> </asp:DetailsView> </p></form>
</
asp:Content>
Error being generated is : You tried to assign the Null value to a variable that is not a Variant data type.
anyone able to help? been on this for a few hours now, i have done it before and never had such problems, loosing motivation now.
![]() |
0 |
![]() |
Hi paul_mc_87 ,
paul_mc_87:
<InsertParameters>
<asp:Parameter Name="Request_ID" Type="Int32" /><asp:Parameter Name="First_Name" Type="String" />Please remove request_id parameter from InsertParameters collection .
Samu Zhang
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
![]() |
0 |
![]() |