I have experienced a problem here while doing a form for accessing datadbase using MS Access. I'm using the AccessDataSourc e 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.Ole Db.OleDbExcepti on: 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.Ole Db.OleDbCommand .ExecuteCommand TextErrorHandli ng(OleDbHResult hr) +65
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextForSingleRe sult(tagDBPARAM S dbParams, Object& executeResult) +181
System.Data.Ole Db.OleDbCommand .ExecuteCommand Text(Object& executeResult) +307
System.Data.Ole Db.OleDbCommand .ExecuteCommand (CommandBehavio r behavior, Object& executeResult) +77
System.Data.Ole Db.OleDbCommand .ExecuteReaderI nternal(Command Behavior behavior, String method) +188
System.Data.Ole Db.OleDbCommand .ExecuteNonQuer y() +112
System.Web.UI.W ebControls.SqlD ataSourceView.E xecuteDbCommand (DbCommand command, DataSourceOpera tion operation) +493
System.Web.UI.W ebControls.SqlD ataSourceView.E xecuteInsert(ID ictionary values) +549
System.Web.UI.D ataSourceView.I nsert(IDictiona ry values, DataSourceViewO perationCallbac k callback) +173
System.Web.UI.W ebControls.Deta ilsView.HandleI nsert(String commandArg, Boolean causesValidatio n) +627
System.Web.UI.W ebControls.Deta ilsView.HandleE vent(EventArgs e, Boolean causesValidatio n, String validationGroup ) +745
System.Web.UI.W ebControls.Deta ilsView.OnBubbl eEvent(Object source, EventArgs e) +162
System.Web.UI.C ontrol.RaiseBub bleEvent(Object source, EventArgs args) +56
System.Web.UI.W ebControls.Deta ilsViewRow.OnBu bbleEvent(Objec t source, EventArgs e) +117
System.Web.UI.C ontrol.RaiseBub bleEvent(Object source, EventArgs args) +56
System.Web.UI.W ebControls.Link Button.OnComman d(CommandEventA rgs e) +107
System.Web.UI.W ebControls.Link Button.RaisePos tBackEvent(Stri ng eventArgument) +175
System.Web.UI.W ebControls.Link Button.System.W eb.UI.IPostBack EventHandler.Ra isePostBackEven t(String eventArgument) +31
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler sourceControl, String eventArgument) +32
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +244
System.Web.UI.P age.ProcessRequ estMain(Boolean includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +3838
--------------------------------------------------------------------------------
DEFAULT.ASPX PAGE CODING
<%@ Page Language="VB" AutoEventWireup ="false" CodeFile="Defau lt.aspx.vb" Inherits="_Defa ult" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:AccessData Source ID="AccessDataS ource1" runat="server" ConflictDetecti on="CompareAllV alues"
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 (?, ?, ?)"
OldValuesParame terFormatString ="original_{ 0}" SelectCommand=" SELECT * FROM [Table1]"
UpdateCommand=" UPDATE [Table1] SET [Name] = ?, [Telphone Number] = ? WHERE [Person ID] = ? AND [Name] = ? AND [Telphone Number] = ?">
<DeleteParamete rs>
<asp:Paramete r Name="original_ Person_ID" Type="Int32" />
<asp:Paramete r Name="original_ Name" Type="String" />
<asp:Paramete r Name="original_ Telphone_Number " Type="Int32" />
</DeleteParameter s>
<UpdateParamete rs>
<asp:Paramete r Name="Name" Type="String" />
<asp:Paramete r Name="Telphone_ Number" Type="Int32" />
<asp:Paramete r Name="original_ Person_ID" Type="Int32" />
<asp:Paramete r Name="original_ Name" Type="String" />
<asp:Paramete r Name="original_ Telphone_Number " Type="Int32" />
</UpdateParameter s>
<InsertParamete rs>
<asp:Paramete r Name="Person_ID " Type="Int32" />
<asp:Paramete r Name="Name" Type="String" />
<asp:Paramete r Name="Telphone_ Number" Type="Int32" />
</InsertParameter s>
</asp:AccessDataS ource>
</div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="Tr ue" AllowSorting="T rue"
AutoGenerateCol umns="False" DataKeyNames="P erson ID" DataSourceID="A ccessDataSource 1"
Style="z-index: 100; left: 10px; position: absolute; top: 59px">
<Columns>
<asp:CommandFie ld ShowDeleteButto n="True" ShowEditButton= "True" ShowSelectButto n="True" />
<asp:BoundFie ld DataField="Pers on ID" HeaderText="Per son ID" InsertVisible=" False"
ReadOnly="True" SortExpression= "Person ID" />
<asp:BoundFie ld DataField="Name " HeaderText="Nam e" SortExpression= "Name" />
<asp:BoundFie ld DataField="Telp hone Number" HeaderText="Tel phone Number" SortExpression= "Telphone Number" />
</Columns>
</asp:GridView>
<asp:DetailsVie w ID="DetailsView 1" runat="server" AllowPaging="Tr ue" AutoGenerateRow s="False"
DataKeyNames="P erson ID" DataSourceID="A ccessDataSource 1" Height="50px" Style="z-index: 102;
left: 16px; position: absolute; top: 355px" Width="125px">
<Fields>
<asp:BoundFie ld DataField="Pers on ID" HeaderText="Per son ID" InsertVisible=" False"
ReadOnly="True" SortExpression= "Person ID" />
<asp:BoundFie ld DataField="Name " HeaderText="Nam e" SortExpression= "Name" />
<asp:BoundFie ld DataField="Telp hone Number" HeaderText="Tel phone Number" SortExpression= "Telphone Number" />
<asp:CommandFie ld ShowDeleteButto n="True" ShowEditButton= "True" ShowInsertButto n="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\Micros oft.Net\Framewo rk\v2.x\Config
-->
<configuratio n>
<appSettings/>
<connectionStri ngs/>
<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="Syst em"/>
<add namespace="Syst em.Collections"/>
<add namespace="Syst em.Collections. Specialized"/>
<add namespace="Syst em.Configuratio n"/>
<add namespace="Syst em.Text"/>
<add namespace="Syst em.Text.Regular Expressions"/>
<add namespace="Syst em.Web"/>
<add namespace="Syst em.Web.Caching"/>
<add namespace="Syst em.Web.SessionS tate"/>
<add namespace="Syst em.Web.Security "/>
<add namespace="Syst em.Web.Profile"/>
<add namespace="Syst em.Web.UI"/>
<add namespace="Syst em.Web.UI.WebCo ntrols"/>
<add namespace="Syst em.Web.UI.WebCo ntrols.WebParts "/>
<add namespace="Syst em.Web.UI.HtmlC ontrols"/>
</namespaces>
</pages>
<!--
The <authentication > section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authenticati on 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="RemoteOnl y" defaultRedirect ="GenericErrorP age.htm">
<error statusCode="403 " redirect="NoAcc ess.htm" />
<error statusCode="404 " redirect="FileN otFound.htm" />
</customErrors>
-->
</system.web>
</configuration>