I'm after some guidance. I have a SQL select statement which pulls a bunch of dates out of my database. I then need to put them into an array or list (i'm not sure which would be best) so that it can be consumed by a jquery script (which will show these dates on a calendar).
My SQL select statement looks like this:
var getBooked = db.Query("SELECT * FROM Property_Availability WHERE PropertyID = @0", rPropertyId);
How do i add these to an array. using a foreach loop?
If you are looking for dates only then this is what you need to select
var getBooked =
db.Query("SELECT myDate FROM Property_Availability WHERE PropertyID = @0"
, rPropertyId).LoList();
This returns a list of dates. I'm adding sample on how to call your method and get and process this list from client
function getDates() {
var myDates= [];
$.ajax({
type: "POST",
url: "yourPage/yourMethod",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
var dates= response.d;
$.map(dates, function (item)
myArray.push(item);
});
alert("success");
},
failure: function (msg) {
alert("fail");
}
});
return myDates;
}
as a result of this function you getting client side array representing your server list