Data Form works on local host, but not on remote server

Discussion in 'ASP.NET / ASP.NET Core' started by annbransom, Jun 27, 2006.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hello, I am new to this so bear with me. I am just now trying to learn ASP.NET web forms and Visual Studio, SQL, etc. Playing around, I made a web form that a person would fill out, click submit, and the remarks would store in the database and display on the page upon postback. It works beautifully on my local host machine and does actually update my database through Discount ASP.NET. However, when I upload the file to the web, fill out the form, andclick submit, I get the following error message:

    Server Error in '/' Application.
    --------------------------------------------------------------------------------

    Inserting is not supported by data source 'NewsAnnouncements' unless InsertCommand is specified.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NotSupportedException: Inserting is not supported by data source 'NewsAnnouncements' unless InsertCommand is specified.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:


    [NotSupportedException: Inserting is not supported by data source 'NewsAnnouncements' unless InsertCommand is specified.]
    System.Web.UI.WebControls.SqlDataSourceView.ExecuteInsert(IDictionary values) +1828255
    System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) +72
    System.Web.UI.WebControls.FormView.HandleInsert(String commandArg, Boolean causesValidation) +388
    System.Web.UI.WebControls.FormView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +623
    System.Web.UI.WebControls.FormView.OnBubbleEvent(Object source, EventArgs e) +95
    System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
    System.Web.UI.WebControls.FormViewRow.OnBubbleEvent(Object source, EventArgs e) +109
    System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
    System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115
    System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +163
    System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102




    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42


    Following is my source code:

    <%@ Page Language="VB" Debug=True%>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">

    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

    End Sub
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Untitled Page</title>
    </head>

    <form id="form1" runat="server">
    <div>
    <table border="0" width="650">
    <tr>
    <td colspan=2 style="text-align: center">
    <span style="font-size: 20px; font-family: Arial"><strong>Ta Da!!!!
    <hr color="#000000" />
    </strong></span>
    </td>
    </tr>
    <tr>
    <td width="225" valign="top">
    <span style="font-family: Verdana; font-size: 10pt;"><strong>Congratulatory Remarks:
    </strong></span>
    <asp:SqlDataSource ID="NewsAnnouncements" runat="server" ConnectionString="<%$ ConnectionStrings:DB_261536_annbransomConnectionString %>"
    SelectCommand="SELECT DISTINCT [NewsID], [Title], [Date], [NewsText] FROM [News]">
    </asp:SqlDataSource>

    <asp:DataList ID="DataList1" runat="server" DataKeyField="NewsID" DataSourceID="NewsAnnouncements"
    Width="200px">
    <ItemTemplate>
    <span style="text-decoration: underline"><strong><span style="font-size: 10pt; color: midnightblue;
    font-family: Verdana">Author:</span> </strong></span>
    <asp:Label ID="TitleLabel" runat="server" Font-Names="Verdana,Arial,Helvetica" Font-Size="Small"
    Font-Underline="True" ForeColor="MidnightBlue" Text='<%# Eval("Title") %>'></asp:Label>
    <span style="font-size: 4pt">

    </span>
    <asp:Label ID="DateLabel" runat="server" Font-Names="Verdana,Arial,Helvetica" Font-Size="Small"
    ForeColor="SteelBlue" Text='<%# Eval("Date") %>'></asp:Label>
    <span style="font-size: 4pt">

    </span>
    <asp:Label ID="NewsTextLabel" runat="server" Font-Names="Verdana,Arial,Helvetica"
    Font-Size="Small" Text='<%# Eval("NewsText") %>'></asp:Label>
    <hr color="#006600" />
    </ItemTemplate>
    </asp:DataList></td>
    <td valign="top" width="425">
    <span style="font-size: 10pt; font-family: Verdana">After much blood, sweat, and tears,
    I finally completed my very first databound web form. Please submit your congratulatory
    remarks through the form below. Your remarks will not only display to the
    left for all to see, but will be forever saved in my SQL database...until I delete
    them. <span style="color: #ff0033"><em>Note: Remark with caution, as you will
    not have the ability to delete them (let's not get carried away after all).</em></span>
    </span>

    <asp:FormView ID="FormView1" runat="server" DataKeyNames="NewsID" DataSourceID="NewsAnnouncements" DefaultMode="Insert" Width="369px">
    <EditItemTemplate>
    NewsID:
    <asp:Label ID="NewsIDLabel1" runat="server" Text='<%# Eval("NewsID") %>'></asp:Label>
    Title:
    <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Title") %>'>
    </asp:TextBox>
    Date:
    <asp:TextBox ID="DateTextBox" runat="server" Text='<%# Bind("Date") %>'>
    </asp:TextBox>
    NewsText:
    <asp:TextBox ID="NewsTextTextBox" runat="server" Text='<%# Bind("NewsText") %>'>
    </asp:TextBox>
    <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
    Text="Update">
    </asp:LinkButton>
    <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
    Text="Cancel">
    </asp:LinkButton>
    </EditItemTemplate>
    <InsertItemTemplate>
    <table align="center" width="400">
    <tr>
    <td><span style="font-size: 10pt; font-family: Verdana">Your Name:</span></td>
    <td><asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox></td>
    </tr>
    <tr>
    <td><span style="font-size: 10pt; font-family: Verdana">Date (mm/dd/yyyy)*: </span></td>
    <td><asp:TextBox ID="DateTextBox" runat="server" Text='<%# Bind("Date") %>'></asp:TextBox></td>
    </tr>
    <tr>
    <td colspan=2><span style="font-family: Verdana"><span style="font-size: 8pt"><em>*For the love of all creatures great and small, I have not learned validation yet, so please don't put a date in the wrong format. God only knows what would happen.</em></span>
    </td>
    </tr>
    <tr>
    <td valign="top"><span style="font-size: 10pt; font-family: Verdana;">Remarks: </span>
    </td>
    <td><asp:TextBox ID="NewsTextTextBox" runat="server" Text='<%# Bind("NewsText") %>' MaxLength="300" Rows="4" TextMode="MultiLine"></asp:TextBox>
    </td>
    </tr>
    <tr>
    <td colspan=2 style="text-align: center">

    <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
    Text="Insert" PostBackUrl="~/Default.aspx"><img src="images/background.gif" border="0" /></asp:LinkButton>
    <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
    Text="Cancel" Visible="False"></asp:LinkButton>
    </td>
    </tr>
    </table>
    </InsertItemTemplate>
    <ItemTemplate>
    NewsID:
    <asp:Label ID="NewsIDLabel" runat="server" Text='<%# Eval("NewsID") %>'></asp:Label>
    Title:
    <asp:Label ID="TitleLabel" runat="server" Text='<%# Bind("Title") %>'></asp:Label>[b]
    Date:
    <asp:Label ID="DateLabel" runat="server" Text='<%# Bind("Date") %>'></asp:Label>[b]
    NewsText:
    <asp:Label ID="NewsTextLabel" runat="server" Text='<%# Bind("NewsText") %>'></asp:Label>[b]
    <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
    Text="Edit"></asp:LinkButton>
    <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
    Text="Delete"></asp:LinkButton>
    <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
    Text="New"></asp:LinkButton>
    </ItemTemplate>
    </asp:FormView>
    [b]
    </td>
    </tr></table>
    [b]
    [b]
    [b]


    </div>
    </form>
    </body>
    </html>


    Please help! I'm a newbie!!!!

    Thanks,

    Ann Bransom
    [email="[email protected]"][email protected][/email][/b][/b][/b][/b][/b][/b][/b]
     
  2. It is strange that it works locally, but not in live.


    What database are you using locally, and what for live?



    Joel Thoms
    DiscountASP.NET
    http://www.DiscountASP.NET
     
  3. That's the REALLY strange thing. My local machine is connecting to my SQL Server Database on Discount ASP.NET's database server. When I try to use my page locally using Visual Web Developer 2005, I click ctrl - F5 to compile, it opens up a browser window that says http://localhost:blah/www.annbransom.com/Default.aspxand Ican fill out the form, click submit, the data displays correctly, and I can go out to"MyLittle Admin" and see that the data has made it to the database.As soon as I upload the file andnavigate to it by http://www.annbransom.com/Default.aspx, though, the data is all displaying but when I click submit I get the error....





    Help!
     
  4. I FINALLY got it to work. I just had to totally start from scratch. Must have been a very well hidden syntax error. Still...don't know why it would work locally then...





    Thanks for the resource! I'm sure I'll be in these forums a lot.


    Ann
     
  5. The worst ones to debug are the ones that work in one location and not another.


    Glad you got it working.









    Joel Thoms
    DiscountASP.NET
    http://www.DiscountASP.NET
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page