UPDATE TWO TABLES using ONE UPDATE COMMAND IN GRIDVIEW SQL DATASOURCE

Posted by Babyeney under ASP.NET on 1/15/2012 | Points: 10 | Views : 6681 | Status : [Member] | Replies : 1
Hi, I'm trying to update two tables using the UPDATE command in gridview using SQL Datasource. Here's my current code, but when I run it, nothing happens when I update the table.

<asp:SqlDataSource ID="SqlDataSource4" runat="server" 
ConnectionString="<%$ ConnectionStrings:HelpDeskDB %>"
SelectCommand="SELECT ticket_no, ticket_status, thread, date_created, last_update, name FROM aspnet_Ticket WHERE (ticket_status = 'PENDING') OR (ticket_status = 'ON-PROCESS')"
UpdateCommand="
UPDATE aspnet_Ticket SET
ticket_no = aspnet_Operation.ticket_no,
ticket_status = aspnet_Operation.ticket_status
FROM aspnet_Ticket
INNER JOIN aspnet_Operation
ON aspnet_Operation.ticket_no = aspnet_Ticket.ticket_no
WHERE aspnet_Operation.ticket_no = aspnet_Ticket.ticket_no">
<UpdateParameters>
<asp:Parameter Name="ticket_status" />
</UpdateParameters></asp:SqlDataSource>





Responses

Posted by: Arefin on: 1/15/2012 [Member] Starter | Points: 25

Up
0
Down
I think your Update SQL is not correct, see again:

UPDATE aspnet_Ticket SET


ticket_no = aspnet_Operation.ticket_no,

ticket_status = aspnet_Operation.ticket_status

FROM aspnet_Ticket

INNER JOIN aspnet_Operation

ON aspnet_Operation.ticket_no = aspnet_Ticket.ticket_no

WHERE aspnet_Operation.ticket_no = aspnet_Ticket.ticket_no


Thanks,
Arefin

Babyeney, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response