Today while developing a page, we felt need to read database into javascript array. And we were confused if at all we can do this. So finally after googling on this we found a workaround. So I just thought of sharing this with you because I think this is really helpful.
<script language=”JavaScript” type=”text/javascript”>
var allRecords = new array();
var count=0;
<%While (NOT rs_yours.EOF)%>
allrecords[count]=”<%= rs_yours.Fields.Item(“foo1″).Value %>”
<%
rs_yours.MoveNext()
Wend
%>
</script>
This script will read the value from your datareader into javascript array.
Also if you want to read a single value from the server side into your javascript like this,
var location=’<%=Session["location"]%>’;
Hope this helps

It is funny, you just showed a small piece of Javascript for looping through an Array, but nowhere in that code did you show how to read database.
In fact, I will post a sample code on my blog to show you how you could do it if you’re struggling with it.
Hey Evans,
I just demonstrated how can we access server side variables / recordset which are most often handled in code behind.
I am aware of using ActivexObjects, would like to know is there any other alternative, looking forward for your post.
Please drop a link of the post when you are done.
Thanks,
Ashish
[...] here to read the rest: Reading Database value in Javascript « Beautiful Mind SHARETHIS.addEntry({ title: "Reading Database value in Javascript « Beautiful Mind", url: [...]