Hi again
Think this is very close to working. I am now getting an error on the update and im not sure what the problem is. Here's the message:
Incorrect syntax near '('.
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.Data.SqlClient.SqlException: Incorrect syntax near '('.
Source Error:
Line 27: acceptOrDeclineFriendship.UpdateParameters.Add("Response", answer)
Line 28: acceptOrDeclineFriendship.UpdateParameters.Add("FriendID", friend_id)
Line 29: acceptOrDeclineFriendship.Update()
Line 30:
Line 31: End Sub |
The full code section is here (I am working in VB):
'retrieve id of requestee and the answer accept/decline
Dim friend_id As String = e.CommandArgument.ToString
Dim answer As String = e.CommandName.ToString
'add the parameters
acceptOrDeclineFriendship.UpdateParameters.Add("Response", answer)
acceptOrDeclineFriendship.UpdateParameters.Add("FriendID", friend_id)
acceptOrDeclineFriendship.Update()
By inserting a breakpoint before the update command, i can see that the values of 'answer' and 'friend_id' have been successfully retrieved. Here is the sqldatasource on page if this makes what im going a bit clearer:
<!---- update query when user has accepted or declined the friendship ---->
<asp:SqlDataSource ID="acceptOrDeclineFriendship" runat="server" ConnectionString="<%$ xxx %>"
UpdateCommand="UPDATE Friends SET (ApprovedByFriend = @Response) WHERE (FriendID = @UserID) AND (UserID = @FriendID)">
<UpdateParameters>
<asp:ControlParameter Name="UserID" ControlID="userIdValue" /> (label control text is set to logged in user's id on page load)
</UpdateParameters>
</asp:SqlDataSource>One thing that is complicating this is that im interchanging UserID and FriendID a lot, in hindsight i should have used 'Invitee' and 'Invited' or something.
Here is how my Friends table works:
ID PK integer
UserID (Invitee) UniqueId
FriendID (Invited) UniqueId
ApprovedByUser True/False/declined whatever
ApprovedByFriend True/False/declined whatever
Requested Date/Time
If anyone knows what is going wrong here I am very grateful for any help at all. Thanks again