I have column in database
ID From To s1from s2to s2price fare
1 Delhi Manali 17-Dec-2010 19-Dec-2010 $900 $600
2 USA Canada 18-Dec-2010 20-Dec-2010 $500 $800
3 Newyork salinas 19-Dec-2010 22-Dec-2010 $760 $1000
I want when any user search For: Delhi to Manali on between 17-Dec-2010 to 19-Dec-2010 then the price would be automatically changes to $900 in gridview else the default price wold be displayed in fare is $600 if he search for DelHi to Manali after 19-Dec-2010.
I m confused how to implement this logic ... using vb.net ...
If I understand correctly, I think you could do using this query:
SELECT DateSpecificFare = CASE WHEN s1from <= inDate AND s2to >= inDate THEN s2price ELSE fare END FROM YourTable WHERE From = inFrom AND To = inTo
Where inDate
, inFrom
and inTo
would be the parameters the user selects.
Your previous query also made it look like you might not know how to make the calls to the database so if that's the case, look at SqlCommand.ExecuteScalar which includes some sample code showing you how to do that. Or if you need to return more than one column and/or record from your table, look at SqlCommand.ExecuteReader instead.
Btw, you should really edit your previous question rather than create a new one, otherwise it might get closed as a duplicate. But in this case I'll answer this one rather than the previous ones since this is the one with the best question.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.