0

hi iam written the update commands very strengthly........
please short them.....
here my commands are.......

conn.Open()
        Dim insert1 As New SqlClient.SqlCommand("update guesthouse set check= 'C' where (date_of_arr >= getdate() and date_of_dept >= getdate()) ", conn)
        Dim insert2 As New SqlClient.SqlCommand("update guesthouse set check= 'O' where (date_of_arr <= getdate() and date_of_dept >= getdate()) ", conn)
        Dim insert3 As New SqlClient.SqlCommand("update guesthouse set check= 'S' where (date_of_arr <= getdate() and date_of_dept <= getdate()) ", conn)
        insert1.ExecuteNonQuery()
        insert2.ExecuteNonQuery()
        insert3.ExecuteNonQuery()
        conn.Close()
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by vizy
0

Hi
Execute your query this way...

update guesthouse set check=
Case
WHEN (date_of_arr >= getdate() and date_of_dept >= getdate())
THEN 'C'
WHEN (date_of_arr <= getdate() and date_of_dept >= getdate())
THEN '0'
WHEN (date_of_arr <= getdate() and date_of_dept <= getdate())
THEN 'S'
ELSE 'X'
END
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.