I have an sql statement that I posted on this site, and I applied in my website that works and inserts users name and information into the database soon after the user presses the submit button.
This however doesnt happen when I set the the submit's buttons PostBackUrl property. When I do this, no data is inserted, and the whole function that holds the execution of the insert statement seems to be skipped (as I tried to make a mistake on purpose,,and no exception was thrown).
How can i make the the postBackUrl work, so that data will have the time to be inserted?
working sqlStatment:
insertCommand.Append("DECLARE @TopicsId int; INSERT INTO Topics(Theme,Topics,Date)");
insertCommand.Append("VALUES(@topic,@subTopic,GETDATE())");
insertCommand.Append("SET @TopicsId = SCOPE_IDENTITY()");
insertCommand.Append(" INSERT INTO Threads(UsersID,TopicsID,Date,ThreadTitle,ThreadParagraph,ThreadClosed,Views,Replies,PageNumber)");
insertCommand.Append(" SELECT @uniqueIdentifier,@TopicsID,GETDATE(),@questionTitle,@questionParagraph,0,0,0,FLOOR(Count(t.TopicsID)/20)");
insertCommand.Append(" FROM Threads AS d INNER JOIN Topics AS t ON d.TopicsID=t.TopicsID");
working when:
<asp:Button ID="sendButton1" runat="server" Text="שלח" Width="60px"
onclick="sendButton1_Click" />
non working sqlStatement when:
<asp:Button ID="sendButton1" runat="server" Text="שלח" Width="60px"
onclick="sendButton1_Click" PostBackUrl="~/AnswerQuestion.aspx" />