I have experienced a problem here while doing a form for accessing datadbase using MS Access. I'm using the AccessDataSource control, and using Gridview to pull the data from the database. I am able to see the contents in the database, but whenever I click "Delete" or "Update", the data never gets deleted or get updated repectively. It feels as if it was a normal page load, nothing is done to the data in the database. I also have another problem is that when I insert new data, the error below is shown to me. I am using Visual Web Developer 2005 Express Edition. I have included my codings and the web.config file. How can I overcome this error? Please help me in this.
Thank you!
--------------------------------------------------------------------------------
ERROR OCCURRED WHEN I INSERT NEW DATA
You tried to assign the Null value to a variable that is not a Variant data type.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: You tried to assign the Null value to a variable that is not a Variant data type.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[OleDbException (0x80004005): You tried to assign the Null value to a variable that is not a Variant data type.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(OleDbHResult hr) +65
System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS dbParams, Object& executeResult) +181
System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult) +307
System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior, Object& executeResult) +77
System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior behavior, String method) +188
System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +112
System.Web.UI.WebControls.SqlDataSourceView.Execut eDbCommand(DbCommand command, DataSourceOperation operation) +493
System.Web.UI.WebControls.SqlDataSourceView.Execut eInsert(IDictionary values) +549
System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) +173
System.Web.UI.WebControls.DetailsView.HandleInsert (String commandArg, Boolean causesValidation) +627
System.Web.UI.WebControls.DetailsView.HandleEvent( EventArgs e, Boolean causesValidation, String validationGroup) +745
System.Web.UI.WebControls.DetailsView.OnBubbleEven t(Object source, EventArgs e) +162
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +56
System.Web.UI.WebControls.DetailsViewRow.OnBubbleE vent(Object source, EventArgs e) +117
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +56
System.Web.UI.WebControls.LinkButton.OnCommand(Com mandEventArgs e) +107
System.Web.UI.WebControls.LinkButton.RaisePostBack Event(String eventArgument) +175
System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +244
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3838
--------------------------------------------------------------------------------
DEFAULT.ASPX PAGE CODING
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" ConflictDetection="CompareAllValues"
DataFile="~/App_Data/db1.mdb" DeleteCommand="DELETE FROM [Table1] WHERE [Person ID] = ? AND [Name] = ? AND [Telphone Number] = ?"
InsertCommand="INSERT INTO [Table1] ([Person ID], [Name], [Telphone Number]) VALUES (?, ?, ?)"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [Table1]"
UpdateCommand="UPDATE [Table1] SET [Name] = ?, [Telphone Number] = ? WHERE [Person ID] = ? AND [Name] = ? AND [Telphone Number] = ?">
<DeleteParameters>
<asp:Parameter Name="original_Person_ID" Type="Int32" />
<asp:Parameter Name="original_Name" Type="String" />
<asp:Parameter Name="original_Telphone_Number" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Telphone_Number" Type="Int32" />
<asp:Parameter Name="original_Person_ID" Type="Int32" />
<asp:Parameter Name="original_Name" Type="String" />
<asp:Parameter Name="original_Telphone_Number" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Person_ID" Type="Int32" />
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Telphone_Number" Type="Int32" />
</InsertParameters>
</asp:AccessDataSource>
</div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="Person ID" DataSourceID="AccessDataSource1"
Style="z-index: 100; left: 10px; position: absolute; top: 59px">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="True" />
<asp:BoundField DataField="Person ID" HeaderText="Person ID" InsertVisible="False"
ReadOnly="True" SortExpression="Person ID" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="Telphone Number" HeaderText="Telphone Number" SortExpression="Telphone Number" />
</Columns>
</asp:GridView>
<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"
DataKeyNames="Person ID" DataSourceID="AccessDataSource1" Height="50px" Style="z-index: 102;
left: 16px; position: absolute; top: 355px" Width="125px">
<Fields>
<asp:BoundField DataField="Person ID" HeaderText="Person ID" InsertVisible="False"
ReadOnly="True" SortExpression="Person ID" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="Telphone Number" HeaderText="Telphone Number" SortExpression="Telphone Number" />
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
</form>
</body>
</html>
--------------------------------------------------------------------------------
WEB.CONFIG FILE
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
Visual Basic options:
Set strict="true" to disallow all data type conversions
where data loss can occur.
Set explicit="true" to force declaration of all variables.
-->
<compilation debug="true" strict="false" explicit="true"/>
<pages>
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
</namespaces>
</pages>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows"/>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
</configuration>