Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Problem in inserting data using DetailsView

Reply
Thread Tools

Problem in inserting data using DetailsView

 
 
le0
Guest
Posts: n/a
 
      09-25-2006
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>

&nbsp;&nbsp;</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.Provider Name %>"

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>

<asparameter Name="original_BookID" Type="Int32" />

<asparameter Name="original_Author" Type="String" />

<asparameter Name="original_YearPublished" Type="Int32" />

<asparameter Name="original_ISBN" Type="String" />

</DeleteParameters>

<UpdateParameters>

<asparameter Name="Author" Type="String" />

<asparameter Name="YearPublished" Type="Int32" />

<asparameter Name="ISBN" Type="String" />

<asparameter Name="original_BookID" Type="Int32" />

<asparameter Name="original_Author" Type="String" />

<asparameter Name="original_YearPublished" Type="Int32" />

<asparameter Name="original_ISBN" Type="String" />

</UpdateParameters>

<InsertParameters>

<asparameter Name="BookID" Type="Int32" />

<asparameter Name="Author" Type="String" />

<asparameter Name="YearPublished" Type="Int32" />

<asparameter Name="ISBN" Type="String" />

</InsertParameters>

</asp:SqlDataSource>

&nbsp;

<aspetailsView 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>

</aspetailsView>

</form>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reusing same DetailsView for both Inserting and Editing David Ching ASP .Net 0 08-29-2007 09:17 PM
Inserting/Updating records in a DetailsView 47computers@gmail.com ASP .Net 0 03-28-2007 12:49 AM
Problems with Walkthrough: Editing and Inserting Data in Web Pages with the DetailsView Web Server Control" tom c ASP .Net 0 09-19-2006 10:11 PM
Default value when inserting new record with the DetailsView Nick ASP .Net 0 02-24-2006 09:01 AM
DetailsView - Changing to Insert Mode (Not By Using the Insert Button In the DetailsView Control) Feege ASP .Net Web Controls 0 12-20-2005 12:28 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57