Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Update with multiple conditions

Author  Topic 

Malathe.A.
Starting Member

10 Posts

Posted - 2009-03-24 : 13:07:37
Hi all..
I'm using SQL Server 2005. I'm trying to use update command with multiple conditions.. I'm using the following code for that purpose.

UpdateCommand="update scheduledetails set conversationdetails=@conversationdetails where companyid=@companyid and cpersonid=@cpersonid and date=@date"

This code is to update the database using a grid view. The update action is not performed.. I assume that the problem may have occurred because of using multiple conditions in update statement..Can u please provide me a solution for this problem..


Thanks & Regards.

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2009-03-24 : 14:24:47
there is no limitation on number of conditions in a WHERE clause. Perhaps there is no data matching the condition. Run a SELECT with same WHERE clause and see if you get any results.. Perhaps you are doing some datatype conversion with one of those parameters and hence not matching any records in your table.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-25 : 13:18:52
how are values for @companyid,@cpersonid .. passed? where are you setting above update statement?
Go to Top of Page

Malathe.A.
Starting Member

10 Posts

Posted - 2009-03-27 : 06:38:01
The select query gives result.. But the update action is not taking place..
Go to Top of Page

Malathe.A.
Starting Member

10 Posts

Posted - 2009-03-27 : 06:40:09
The values are passed from gridview control.. I'm trying to update the database using the gridview. When i want to update a particular row in gridview i can edit n update it to the database. Updation is not taking place.. Suggest me a sollution.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-28 : 03:25:54
quote:
Originally posted by Malathe.A.

The values are passed from gridview control.. I'm trying to update the database using the gridview. When i want to update a particular row in gridview i can edit n update it to the database. Updation is not taking place.. Suggest me a sollution.


use profiler and trace out statement executed by application to see if values are passed correctly.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-28 : 03:26:38
also check if you've any update triggers (instead of or after) present in table
Go to Top of Page
   

- Advertisement -