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" />
|