I have a doubt I want to connect database in my ASP.net application using java script to run faster. As in serverside its bit slow as anytime the postback method is calling so I think client side will be faster So is it possible ?
Like you said JavaScript is client side and the db is on the server. So how do you think it connects? Javascript can't do it. You will always need a server side scripting language to do this.
These is simple, YOU CAN'T. Javascript is clientside you can't connect it to a database on the serverside.
no you can't. javascript is client-side scripting, database is server-side.. however you can communicate with it through AJAX..
Although javascript is client-side you can retrieve the data through AJAX after the initial page load. This would be beneficial if you are seeing a slow initial load-time when going to the page initially. Have the javascript call an ajax function on load that retrieves the data necessary to populate the page.
Yes that's right but that is not what the original question was. AJAX still requires a server side script and does not connect directly to the database
I was merely giving suggestions on how to make his application potentially faster. Other people had already answered his original question. Was this wrong of me?
demonbyte, there is a big flaw with what you've suggested that will cause big problems for the guys client. Even if you rely on AJAX, turn javascript off and the site is dead, also you don't want a standalone connect script for your DB connection exposing. If your dynamically retrieving say comment updates, the method you suggest is fine as its a trivial bit of content (i.e. load 10 comments natively then update the list periodically with JavaScript/AJAX). As if JS is turned off, the list simply wont auto update, so it degrades well (provided you have native navigation). Not picking at you, but I'd say it was a bit of bad advice, when I think the answer is no you can't without AJAX and you shouldn't depend on that either. Also, worth considering, if you do it by AJAX and do go with it, and have say 10 items on the page, each calling your DB you are potentially making 10 separate connections to the DB Server, when inside say PHP or ASP.NET you can do it with one connection and flow it through nicely. So potentially the AJAX method would be slower under load.