L
le0
Guys,
I create a simple insertion in a database using DetailsView control, when i
run this page and try to insert some data, the browser returns an error like
this
---------------------------------------------------------------------------------------------------------------
Server Error in '/Document' Application.
You tried to assign the Null value to a variable that is not a Variant data
type
Description: An unhandled exception occured during the execution of the
current web request.
----------------------------------------------------------------------------------------------------------------
i filled up all fields that is required and follow all its data type to make
sure no errors will return, but that doesnt solve my problem, can you figure
this out? btw i use MS Access as my database.
heres my code for your reference...
<form id="form1" runat="server">
<div>
</div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:MyBooksConnectionString %>"
DeleteCommand="DELETE FROM [Book1] WHERE [BookID] = ? AND [Author] = ? AND
[YearPublished] = ? AND [ISBN] = ?" InsertCommand="INSERT INTO [Book1]
([BookID], [Author], [YearPublished], [ISBN]) VALUES (?, ?, ?, ?)"
ProviderName="<%$ ConnectionStrings:MyBooksConnectionString.ProviderName %>"
SelectCommand="SELECT [BookID], [Author], [YearPublished], [ISBN] FROM
[Book1]" UpdateCommand="UPDATE [Book1] SET [Author] = ?, [YearPublished] =
?, [ISBN] = ? WHERE [BookID] = ? AND [Author] = ? AND [YearPublished] = ?
AND [ISBN] = ?" ConflictDetection="CompareAllValues"
OldValuesParameterFormatString="original_{0}">
<DeleteParameters>
<asp
arameter Name="original_BookID" Type="Int32" />
<asp
arameter Name="original_Author" Type="String" />
<asp
arameter Name="original_YearPublished" Type="Int32" />
<asp
arameter Name="original_ISBN" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp
arameter Name="Author" Type="String" />
<asp
arameter Name="YearPublished" Type="Int32" />
<asp
arameter Name="ISBN" Type="String" />
<asp
arameter Name="original_BookID" Type="Int32" />
<asp
arameter Name="original_Author" Type="String" />
<asp
arameter Name="original_YearPublished" Type="Int32" />
<asp
arameter Name="original_ISBN" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp
arameter Name="BookID" Type="Int32" />
<asp
arameter Name="Author" Type="String" />
<asp
arameter Name="YearPublished" Type="Int32" />
<asp
arameter Name="ISBN" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp
etailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
DataKeyNames="BookID"
DataSourceID="SqlDataSource1" Height="50px" Style="z-index: 100; left: 14px;
position: absolute; top: 77px" Width="125px">
<Fields>
<asp:BoundField DataField="BookID" HeaderText="BookID" InsertVisible="False"
ReadOnly="True"
SortExpression="BookID" />
<asp:BoundField DataField="Author" HeaderText="Author"
SortExpression="Author" />
<asp:BoundField DataField="YearPublished" HeaderText="YearPublished"
SortExpression="YearPublished" />
<asp:BoundField DataField="ISBN" HeaderText="ISBN" SortExpression="ISBN" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
</asp
etailsView>
</form>
I create a simple insertion in a database using DetailsView control, when i
run this page and try to insert some data, the browser returns an error like
this
---------------------------------------------------------------------------------------------------------------
Server Error in '/Document' Application.
You tried to assign the Null value to a variable that is not a Variant data
type
Description: An unhandled exception occured during the execution of the
current web request.
----------------------------------------------------------------------------------------------------------------
i filled up all fields that is required and follow all its data type to make
sure no errors will return, but that doesnt solve my problem, can you figure
this out? btw i use MS Access as my database.
heres my code for your reference...
<form id="form1" runat="server">
<div>
</div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:MyBooksConnectionString %>"
DeleteCommand="DELETE FROM [Book1] WHERE [BookID] = ? AND [Author] = ? AND
[YearPublished] = ? AND [ISBN] = ?" InsertCommand="INSERT INTO [Book1]
([BookID], [Author], [YearPublished], [ISBN]) VALUES (?, ?, ?, ?)"
ProviderName="<%$ ConnectionStrings:MyBooksConnectionString.ProviderName %>"
SelectCommand="SELECT [BookID], [Author], [YearPublished], [ISBN] FROM
[Book1]" UpdateCommand="UPDATE [Book1] SET [Author] = ?, [YearPublished] =
?, [ISBN] = ? WHERE [BookID] = ? AND [Author] = ? AND [YearPublished] = ?
AND [ISBN] = ?" ConflictDetection="CompareAllValues"
OldValuesParameterFormatString="original_{0}">
<DeleteParameters>
<asp
<asp
<asp
<asp
</DeleteParameters>
<UpdateParameters>
<asp
<asp
<asp
<asp
<asp
<asp
<asp
</UpdateParameters>
<InsertParameters>
<asp
<asp
<asp
<asp
</InsertParameters>
</asp:SqlDataSource>
<asp
DataKeyNames="BookID"
DataSourceID="SqlDataSource1" Height="50px" Style="z-index: 100; left: 14px;
position: absolute; top: 77px" Width="125px">
<Fields>
<asp:BoundField DataField="BookID" HeaderText="BookID" InsertVisible="False"
ReadOnly="True"
SortExpression="BookID" />
<asp:BoundField DataField="Author" HeaderText="Author"
SortExpression="Author" />
<asp:BoundField DataField="YearPublished" HeaderText="YearPublished"
SortExpression="YearPublished" />
<asp:BoundField DataField="ISBN" HeaderText="ISBN" SortExpression="ISBN" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
</asp
</form>