Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8
This is the forum to discuss the Wrox book Beginning ASP.NET 2.0 by Chris Hart, John Kauffman, David Sussman, Chris Ullman; ISBN: 9780764588501
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 18th, 2008, 08:37 PM
Authorized User
 
Join Date: Dec 2008
Posts: 56
Thanks: 1
Thanked 1 Time in 1 Post
Send a message via MSN to fh84
Default Uploading files with records creation p.279

when i try to create a new record then a run time error appears. the image is uploaded on the the site but after......have no database knowledge!!!!

this is the code...

Cannot insert the value NULL into column 'PictureID', table 'D:\FINAL YEAR\PROJECT\WEBSITE\APP_DATA\OSFPDB.MDF.dbo.Galle ry'; column does not allow nulls. INSERT fails.
The statement has been terminated.

<asp:Label ID="FileUploadReport" runat="server"></asp:Label>
<asp:FileUpload ID="FileUpload1" runat="server" />
<br />
<br />
<asp:ListBox ID="ListBox1" runat="server" DataSourceID="SqlDataSourceFixtures"
DataTextField="FixtureDate" DataValueField="FixtureID"></asp:ListBox>
<asp:SqlDataSource ID="SqlDataSourceFixtures" runat="server"
ConnectionString="<%$ ConnectionStrings:WroxUnited %>"
SelectCommand="SELECT [FixtureID], [FixtureDate] FROM [Fixtures] ORDER BY [FixtureDate]">
</asp:SqlDataSource>
<br />
<br />
<asp:Label ID="Label2" runat="server" Text="Fan's Name"></asp:Label>
<asp:TextBox ID="TextBoxMemberName" runat="server"></asp:TextBox><br />
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Comments"></asp:Label>
<asp:TextBox ID="TextBoxNotes" runat="server"></asp:TextBox><br />
<br />
<asp:SqlDataSource ID="SqlDataSourceCreateGalleryRecord" runat="server"
ConnectionString="<%$ ConnectionStrings:WroxUnited %>"
OldValuesParameterFormatString="original_{0}"
InsertCommand="INSERT INTO [Gallery] ([FixtureID], [UploadedByMemberName], [Notes], [PictureURL]) VALUES (@FixtureID, @UploadedByMemberName, @Notes, @PictureURL)">
<InsertParameters>
<asp:ControlParameter Name="FixtureID" Type="Int64" ControlID="ListBox1" PropertyName="SelectedValue"/>
<asp:ControlParameter Name="UploadedByMemberName" Type="String" ControlID="TextBoxMemberName" PropertyName="Text" />
<asp:ControlParameter Name="Notes" Type="String" ControlID="TextBoxNotes" PropertyName="Text" />
<asp:ControlParameter Name="PictureURL" Type="String" ControlID="FileUpload1" PropertyName="FileName"/>
</InsertParameters>
</asp:SqlDataSource>
<br />
<asp:Button ID="Button1" runat="server" Text="Upload"
onclick="Button1_Click" />
 
Old December 19th, 2008, 05:00 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Difficult to say without seeing your database and without having the book. I checked the download code, but can't find the page that contains his code.

Anyway, as the error suggests, you're not supplying a value for a required column. Maybe PictureID is the primary key but has not been set as an identity?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
uploading files vinoskiboyetski Beginning PHP 1 November 28th, 2007 02:30 PM
C# app doesn't release files after creation gandaliter C# 2005 0 April 13th, 2007 12:40 PM
uploading files rj1406 ASP.NET 1.0 and 1.1 Basics 1 October 11th, 2004 10:27 AM
Uploading files mildge Beginning PHP 6 December 1st, 2003 12:42 PM
uploading files by c# rborsatti C# 2 September 29th, 2003 03:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.