Maybe someone can help me. I am trying to insert info from textboxes into the database and do an upload to a file on a server as well. The upload works fine. However, nothing is written to the database. The database has an autonumber pk. The row is created but none of the data is stored. Can someone help? My code is listed below.
[CODE]<%@ Page Language=“VB” %>
<%@ Import Namespace=“System.IO ” %>
Upload Photo
<!-- Set Name Properties -->
<asp:Label ID="nameLabel" runat="server" Text="Name:" />
</td><td>
<asp:TextBox ID="nameTextBox" runat="server" Text='<%# Bind("name")%>' />
</td></tr><tr><td>
<!-- Set Address Properties -->
<asp:Label ID="phoneLabel" runat="server" Text="Phone:" />
</td><td>
<asp:TextBox ID="phoneTextBox" runat="server" Text='<%# Bind("phone")%>' />
</td></tr><tr><td>
<!-- Set Email Properties-->
<asp:Label ID="emailLabel" runat="server" Text="E-Mail:" />
</td><td>
<asp:TextBox ID="emailTextBox" runat="server" Text='<%# Bind("email")%>' />
</td></tr><tr><td valign="top">
<!-- Set Comments Properties-->
<asp:Label ID="commentsLabel" runat="server" Text="Notes:" />
</td><td>
<asp:TextBox ID="commentsTextBox" runat="server" Width="240px" Text='<%# Bind("comments")%>' TextMode="MultiLine" /><br /><br />
</td></tr><tr><td valign="top">
<!-- Set File Properties -->
<asp:Label
ID="lblFile1" Text="Photo:" AssociatedControlID="file1" Runat="server" />
</td><td>
<asp:FileUpload ID="file1" Runat="server" FileName='<%# Bind("file1") %>' />
<br />
<asp:FileUpload ID="file2" Runat="server" FileName='<%# Bind("file2") %>' />
<br />
<asp:FileUpload ID="file3" Runat="server" FileName='<%# Bind("file3") %>' />
<br />
<asp:FileUpload ID="file4" Runat="server" FileName='<%# Bind("file4") %>' />
<br />
<asp:FileUpload ID="file5" Runat="server" FileName='<%# Bind("file5") %>' />
<br />
<asp:Button ID="btnSubmit" Text="Submit" CommandName="Insert" onClick="btnSubmit_Click" Runat="server" />
</td></tr></table>
</InsertItemTemplate>
</asp:FormView>
<asp:SqlDataSource
id="srcPhotos" Runat="server" ConnectionString="<%$ ConnectionStrings:bowlher_sunmansConnectionString %>"
SelectCommand="SELECT * FROM photos"
InsertCommand="INSERT INTO [photos] ([name], [phone], [email], [comments], [file1], [file2], [file3], [file4], [file5]) VALUES (@name, @phone, @email, @comments, @file1, @file2, @file3, @file4, @file5)">
<InsertParameters>
<asp:Parameter Name="name" Type="String" />
<asp:Parameter Name="phone" Type="String" />
<asp:Parameter Name="email" Type="String" />
<asp:Parameter Name="comments" Type="String" />
<asp:Parameter Name="file1" Type="String" />
<asp:Parameter Name="file2" Type="String" />
<asp:Parameter Name="file3" Type="String" />
<asp:Parameter Name="file4" Type="String" />
<asp:Parameter Name="file5" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
</form>
[/CODE]
antic
October 22, 2008, 5:08am
2
Might be off the mark here, but I don’t see any SQL statements in your code… so how do you access your database?
Ravi
October 23, 2008, 6:45am
3
To my understanding of database, you have to update the database to commit changes (addition, modification), specially in MSSQL.
Please see if you are missing any related code, before closing the connection string.
Hey guys thanks for the replies. I tried everything and nothing worked. I rebuilt the application with pretty much identical code and it worked. So I’m not sure what the problem was but it is fixed now.
antic
October 24, 2008, 2:00am
5
I guess this is the problem with these integrated IDE’s… you can show us the code, but you can’t show us all the objects and properties you’ve set in the IDE, like for the data source, bound fields etc. So the bug was probably something to do with that, and not the actual typed code.