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.
| Author |
Topic |
|
majidbhutta
Starting Member
13 Posts |
Posted - 2005-12-03 : 06:12:10
|
| DateTime Updating Problem in sql?below is the query that is a part of a sproc .All table fields and values are ok. When the mentioned Sproc. is called in query analyzer it executes well and update all fields of the table used in UPDATE statement.UPDATE Emp_ScheduleSET IOS = 0, HoursWorked = @WorkTime, COA =getdate()WHERE (Emp_Id = @EmpID) AND (S_Id = @ShiftId) AND (DT =@DayTime)PROBLEM arises when i call this procedure from C# code all fields are updated Except the COA(DateTime) field.Whats the problem. SProc runs well both in debug mode and normal mode in query analyzer and do updates the values. But when i call in C# only datetime field COA is not Updated? Plz solve this.THNX IN Advance. |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2005-12-03 : 06:26:47
|
| what format you are passing the date.from the C#..??Check the format.. and in the store proc you change.. the format using Convert FunctionSucess Comes to those who Believe in Beauty of their Dream.. |
 |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2005-12-03 : 13:10:26
|
quote: and in the store proc you change.. the format using Convert Function
You shouldn't ever need to do that for a simple update from an application. As chir mentioned, show us the actual call that's being passed from C#, including the parameters.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
majidbhutta
Starting Member
13 Posts |
Posted - 2005-12-03 : 22:01:54
|
| Thnx For Suggestion Actually i was not Calling the Actual Sproc but the other one with little bit Simailar Name that was Updating all fields but not DateTime . Now i tracked doewn the code and everything is Ok |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2005-12-04 : 00:09:48
|
that explain the mystery.as COA is updated inside the SP with getdate(). If other columns are updated there isn't any reason COA is not being updated.-----------------[KH] |
 |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2005-12-04 : 08:50:06
|
| I agree with Khtan, its best to update your date in your SP with the getdate() function |
 |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2005-12-04 : 12:56:30
|
| There are exceptions to this guys. Be careful giving blanket advice. What if the date isn't getdate() at all? What if there is a batch process and you want the "batch" date to be placed throughout all the procedures with the same date? What if the date is something driven outside of the database?GETDATE() is a good thing to use when it can provide simplicity and the right answer effectively. It's a tool though. Like all tools, it has it's place.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
|
|
|