November 8, 2013 at 4:56 am
Hi,
I have a grid like this and when I change Designation value of Name X from PA to PAT, this change should reflect to Sathish Designation too. Changing similar values should reflect all over the grid. Like update database on change of value of similar kind. Any suggestions on update query?
By far I use this query to update the grid. So a where clause should be used now to update the grid to fit this scenario. Correct me if I am wrong.
("UPDATE AppInvent_Test SET Name = @Name, Designation = @Designation, City = @City WHERE EmpID = @EmpID");
EmpID Name Designation City
21XPAChn
2SathishPAChn
3ShivaACbe
17VenkatMHyd
22YSMCbe
18VigneshSAHyd
Table:
CREATE TABLE [dbo].[AppInvent_Test](
[EmpID] [int] IDENTITY(1,1) NOT NULL,
[Name] [varchar](100) NULL,
[Designation] [varchar](100) NULL,
[City] [varchar](50) NULL
) ON [PRIMARY]
insert into AppInvent_Test values('X', 'PA','Chn');
insert into AppInvent_Test values('Sathish', 'PA','Chn');
insert into AppInvent_Test values('Shiva', 'A','Cbe');
insert into AppInvent_Test values('Venkat', 'M','Hyd');
insert into AppInvent_Test values('Y', 'SM','Cbe');
insert into AppInvent_Test values('Vignesh', 'SA','Hyd');
November 8, 2013 at 5:10 am
vigneshlagoons (11/8/2013)
Hi,I have a grid like this and when I change Designation value of Name X from PA to PAT, this change should reflect to Sathish Designation too. Changing similar values should reflect all over the grid. Any suggestions on update query?
By far I use this query to update the grid. So a where clause should be used now to update the grid to fit this scenario. Correct me if I am wrong.
("UPDATE AppInvent_Test SET Name = @Name, Designation = @Designation, City = @City WHERE EmpID = @EmpID");
EmpID Name Designation City
21XPAChn
2SathishPAChn
3ShivaACbe
17VenkatMHyd
22YSMCbe
18VigneshSAHyd
Table:
CREATE TABLE [dbo].[AppInvent_Test](
[EmpID] [int] IDENTITY(1,1) NOT NULL,
[Name] [varchar](100) NULL,
[Designation] [varchar](100) NULL,
[City] [varchar](50) NULL
) ON [PRIMARY]
insert into AppInvent_Test values('X', 'PA','Chn');
insert into AppInvent_Test values('Sathish', 'PA','Chn');
insert into AppInvent_Test values('Shiva', 'A','Cbe');
insert into AppInvent_Test values('Venkat', 'M','Hyd');
insert into AppInvent_Test values('Y', 'SM','Cbe');
insert into AppInvent_Test values('Vignesh', 'SA','Hyd');
If you want to update the row being edited, your update statement looks right.
Your statement "Changing similar values should reflect all over the grid" has me curious. Are you saying that if someone edits the designation PA for EmpID 1 that PA should be changed in all rows? This definitely isn't what I would consider normal behavior for an application. This would be better handled by a foreign key to a designations table. If you do fire an update statement for each individual field with it's own where clause, you should clearly identify how the application works in the GUI. My hope is that I'm misinterpreting what I'm reading.
November 13, 2013 at 5:24 am
Hi Ed,
It's like I have a grid where I use a checkbox for bulk update by selecting multiple rows. Now I placed a footer template with the textbox below the grid. Assume like I select two rows in the grid(using checkbox) and when I enter values in the textbox in footertemplate below the grid, then changes have to be reflected to the selected rows in the grid for the columns(Saved to the DB). So you think the same update query will work for this scenario too. Any suggestions pls?
November 14, 2013 at 3:51 am
Hi,
Hope this may help you..
update AppInvent_Test set Designation='PAT' where EmpID in (1,2)
Regards,
Revathy
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply