View Single Post

   
  #3 (permalink)  
Old 02-28-2008, 07:15 PM
A Rugchatjaroen
 
Posts: n/a
Default Re: Could I use SQL "Select Case .. When..." in ADODB.Recordset().open



Thank you Erland Sommarskog. I use VS.net webservice to connect SQL
server. Could I try with the following code (I'm not sure that I can use
"SELECT CASE" sql with this or not)
'Dim objADORS_ As New ADODB.Recordset()
'objADORS_.Open("SELECT CASE
DateDiff('d',[tblHeader].[start_Weekend]," & to_date & ")" & _
' " WHEN 0 THEN sum([tblTimeSheet].[sat]) +
sum[tblMiscellenous].[sat]" & _
' " WHEN 1 THEN sum([tblTimeSheet].[sun]) +
sum[tblMiscellenous].[sun]" & _
' " WHEN 2 THEN sum([tblTimeSheet].[mon]) +
sum[tblMiscellenous].[mon]" & _
' " WHEN 3 THEN sum([tblTimeSheet].[tue]) +
sum[tblMiscellenous].[tue]" & _
' " WHEN 4 THEN sum([tblTimeSheet].[wed]) +
sum[tblMiscellenous].[wed]" & _
' " WHEN 5 THEN sum([tblTimeSheet].[thu]) +
sum[tblMiscellenous].[thu]" & _
' " WHEN 6 THEN sum([tblTimeSheet].[fri]) +
sum[tblMiscellenous].[fri]" & _
' " ELSE 0 " & _
' " END as HrsUsed" & _
'" FROM(tblHeader, tblTimeSheet, tblMiscellenous)" & _
'" WHERE(tblHeader.HID = tblTimeSheet.HID and
tblHeader.HID=tblMiscellenous.HID) " & _
'" and ('" & to_date & "' between
[tblHeader].[start_weekend] and [tblHeader].[end_weekend])" & _
'" and tblHeader.initial = '" & ini & "'" & _
'" GROUP BY [tblHeader].[start_Weekend]")

thank you for your kindness ans.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Reply With Quote