SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Update Problem
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

immad
Posting Yak Master

Pakistan
218 Posts

Posted - 07/19/2013 :  03:16:43  Show Profile  Reply with Quote
hello

i want to update a data in grid view

i have three columns in grid view

first two column are shift id and date these two column are taken from table 1
the third column is shift column this column are taken from table 2

now i want to update a data where shift id and shift column are same

table 2 have these column
shift
shiftid

and table 1 has these column
shift id,
date

please can u provide me a update query syntax

thanks

immad uddin ahmed

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 07/19/2013 :  03:55:11  Show Profile  Reply with Quote
update which field? with what value?
You just specfied criteria but did give us any information on column to be updated and value to be used

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

immad
Posting Yak Master

Pakistan
218 Posts

Posted - 07/19/2013 :  05:54:57  Show Profile  Reply with Quote
quote:
Originally posted by visakh16

update which field? with what value?
You just specfied criteria but did give us any information on column to be updated and value to be used

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs




update shift column with shift id

for example

shift id------------shift
---1-----------------A
---2-----------------B

after execute query data shows this result

shift id----------------shift
----1--------------------C
----2--------------------B


immad uddin ahmed

Edited by - immad on 07/19/2013 05:56:12
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 07/19/2013 :  06:25:20  Show Profile  Reply with Quote
Where does C ad B come from? They're not values present in shift id column so your statement below is incorrect

update shift column with shift id


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

immad
Posting Yak Master

Pakistan
218 Posts

Posted - 07/19/2013 :  06:37:48  Show Profile  Reply with Quote

I EXPLAIN U IN DETAIL

I AM MAKING A APPLICATION IN c# THERE IS A GRID THAT SHOWS

SHIFT ID , SHIFT AND DATE

USER SEARCH DATE AND IN GRID DATE , SHIFT AND SHIFT ID SHOWS

THEN USER CHANGE SHIFT AND ON SHIFT TABLE THAT SHIFT NAME CHANGE OF THAT ID.

SHIFT ID AND DATE COME FROM SHIFT DETAILS TABLE

THIS IS A DATA

SHIFT ID----------DATE
-----1------------1/1/2013
-----2------------2/1/2013
-----3-----------4/5/2013
-----4------------6/24/2013

AND SHIFT COME FROM SHIFT TABLE

THIS IS A DATA OF SHIFT TABLE

SHIFT ID----------SHIFT
-----1------------A
-----2------------B
-----3-----------C
-----4------------D


WHEN USER EXECUTE UPDATE QUERY ITS CHANGES SHIFT COLUMN VALUE OF SHIFT TABLE

I HOPE U UNDER STAND SIR

ONE THING MORE HE CAN ONLY CHANGE A SHIFT FROM THE GRID HE CANNOT CHANGE ID


immad uddin ahmed
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 07/19/2013 :  06:51:49  Show Profile  Reply with Quote
sounds like this to me

query to serach and get shift details


SELECT [DATE],SHIFT,SHIFTID
FROM Table
WHERE [DATE]= @DateValue

@Datevalue you pass from application

Now when user edit a SHIFT you'll fire a query like this

UPDATE s
SET s.SHIFT= @YourNewShiftValue
FROM SHIFT s
WHERE SHIFTID=@ShiftID

Where @YourNewShiftValue will be tha value user changes in grid
and @ShiftID will have id of the row that user modifies as its value

you need to write code in C# to form the above sql queries in your c# code, pass them to db and execute



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000