Click to See Complete Forum and Search --> : javascript and database
fuwsdotnet
10-10-2003, 11:54 PM
i have to write a web survay for a class using asp. I didnt want to use vb like everyone else so i decided to use javascript. This seems to be a big mistake since most people dont even think you can do severside js. But hopefully you guys can help me out. Can somebody point me to a how-to on serverside js specificaly database interaction. alll sample code, ideas, how-to or even flames (im losing hair trying to find this information) such as connection strings or running quieries would be greatly apreciated.
john
Khalid Ali
10-11-2003, 09:09 AM
if you want to use JavaScript server side,then there is alots of other stuff you will need to take into account.
JS server side only works for IPlanet webservers.(Netscape webservers)
You seem to be using ASP so I think you are on a collision course here..
:D
And I seriously doubt that you will buy an IPlanet Application server for this.
use php,JSP or as you already are using ASP
gil davis
10-11-2003, 10:13 AM
Originally posted by Khalid Ali:
JS server side only works for IPlanet webservers.(Netscape webservers)
Microsoft IIS supports JScript.
Originally posted by fuwsdotnet
Can somebody point me to a how-to on serverside js specificaly database interaction.
I believe that Micro$oft wants to keep this a deep dark secret. However, I was just scribbling around and discovered that most of the ADO stuff works in JScript as long as you remember case sensitivity. Here is an example page I made:
<%@ LANGUAGE="JavaScript" %>
<%
accessDB = Server.MapPath("dlytxt.mdb");
strconn = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=";
strconn = strconn + accessDB + ";";
mySQL = "select * from dt2003";
conntemp = Server.CreateObject("adodb.connection");
conntemp.Open(strconn);
rstemp = conntemp.Execute(mySQL);
howmanyfields = rstemp.Fields.Count;
%>
<table border>
<tr>
<% for (var i=0; i<howmanyfields; i++)
{Response.Write("<th>" + rstemp.Fields(i).Name + "</th>\n");}
%>
</tr>
<%
while (!rstemp.Eof) {
Response.Write("<tr>\n");
for (i=0; i<howmanyfields; i++)
{Response.Write("<td>" + rstemp(i) + "</td>\n");}
Response.Write("</tr>\n");
rstemp.moveNext; }
%>
</table>
<%
rstemp.Close;
rstemp = null;
conntemp.Close;
conntemp = null;
%>
HTH.
This link was fairly helpful: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iisref/htm/workingwithscriptinglanguages.asp
Khalid Ali
10-11-2003, 10:34 AM
Originally posted by gil davis
Microsoft IIS supports JScript.
.........
I think you got mislead by me using JS
which was intended to be read as "JavaScript" not "JScript"
the code segment you proposed is only JScript specific which is a MS technology(however similar to JavaScript), And it will not work on any other webserver other then MS IIS
I am pretty sure that no other server then Netscape servers support JavaScript Server side
Vladdy
10-11-2003, 11:59 AM
JScript and Javascript are the same when it comes to syntax. You can access all the same objects with JScript that you do with VBScript when programming within ASP environment.
Personally, I exclusively use JSCript when doing ASP projects.
gil davis
10-11-2003, 02:27 PM
I think that the key part of the original post that Khalid seems to have missed was that fuwsdotnet was already trying to use ASP. Since that is a Micro$oft proprietary server technology, all the rest of Khalid's discussion is not relevant.
It probably should have been moved over to the ASP forum, anyway.
Khalid Ali
10-11-2003, 04:22 PM
Originally posted by fuwsdotnet
on serverside js specificaly database interaction.
I think your(Gil's) comments are a bit harsher when you say that what I posted was irrelevant.
Original poster specifcaly asked about JavaScript (not JScript) to be used with ASP for db connectivity.
now if I am wrong then I stand corrected,other wise here is an example that I took from netscape site.
<p>You are using <server>write(request.agent)</server>
I will end this discussion right here if this statement will work in ASP,however the above will work on IPlanets webserver that support JavaScript Server-Side scripting.
And as far as JSCript and JavaScript being the same is concern,
I agree to the extent that they do have the same core data objects such as
Objects,Arrays, Functions, Numbers etc
But browser specific objects such as,
window,document,image's implenetation is completely browser dependant(though the differences seem to be reducing).
The point is JavaScript server side is different and JScript server side is different,
I respect Gil's opinion but I'll be really happy to find any resources where he can tell me that JScript uses LiveConnect to perform datanbase operations.I could be wrong but to my knowledge its only JavaScript in Netscape server environment that use LiveConnect.
I agree that we should move it to ASP forum,because, after all it is MS technology specific question.
gil davis
10-11-2003, 08:23 PM
Originally posted by Khalid Ali
I think your(Gil's) comments are a bit harsher when you say that what I posted was irrelevant.Sorry. Not trying to be harsh.<p>You are using <server>write(request.agent)</server>There is a world of difference between Netscape's implementation of server-side JavaScript and Micro$oft's ASP. However, it is still an implementation of JavaScript, even if it is has capabilities beyond actual ECMA-script.I will end this discussion right here if this statement will work in ASP,however the above will work on IPlanets webserver that support JavaScript Server-Side scripting.In my mind, that really wasn't the point of contention. Actually, I don't believe that what I posted was ECMA-script any more than I believe that what you posted was ECMA-script. The "<SERVER>" tag is HTML that tells the server that the enclosed text is a server-side script, and I really would not have expected that to work in an ASP page. I do not know about JSP (actually, I am just now learning ASP), but I would suspect that the files are much different from client-side javascript.The point is JavaScript server side is different and JScript server side is different,I agree.I respect Gil's opinion but I'll be really happy to find any resources where he can tell me that JScript uses LiveConnect to perform datanbase operations.I could be wrong but to my knowledge its only JavaScript in Netscape server environment that use LiveConnect.LiveConnect is Netscape's way of allowing JavaScript to communicate with Java and plug-ins in the browser side. I think perhaps you meant to say LiveWire, which is the Netscape Enterprise term for database access. I could not find anything on the new DevEdge site, but I found this link in the Archived Developer web site: http://developer.netscape.com/viewsource/index_frame.html?content=husted_js/husted_js.html It talks about the differences in server-side and client-side JS in Netscape.I agree that we should move it to ASP forum,because, after all it is MS technology specific question. Oh, yes, please;)
Originally posted by gil davis
(actually, I am just now learning ASP)Just out of curiosity (don't want to get into yet another PHP vs. ASP debate) but I'm curious why you chose ASP over PHP? Any specific reasons, or are you just more comfortable with the VB syntax?
gil davis
10-11-2003, 09:06 PM
Originally posted by pyro
Just out of curiosity (don't want to get into yet another PHP vs. ASP debate) but I'm curious why you chose ASP over PHP? Any specific reasons, or are you just more comfortable with the VB syntax? I am currently studying to become certified in MCDBA, and I have implemented a Windows 2000 Server at home for practice. It comes with IIS Server which supports ASP and CGI.
My ISP is AT & T, and they do not support scripting of any kind on the personal web pages server. It was never a consideration before and I never bothered trying any other server-side technologies, since I didn't have anywhere to apply it. I am not inclined to change my ISP just for that, so here I sit, playing on my home computers.
I suppose I'll get around to CGI eventually. It seemed easier to transit into VBScript and ASP. I've been using BASIC for ever (so it seems). I also know Pascal and a little C. I picked up JavaScript because it was similar to Pascal, and you could implement some pretty neat things on client-side.
Ah, yes. With MCDBA, it would be logical to learn ASP over PHP. You going to be looking for a job as a DB administrator, then? Anyway, best of luck, man... :)
fuwsdotnet
10-12-2003, 06:56 PM
Originally posted by pyro
Just out of curiosity (don't want to get into yet another PHP vs. ASP debate) but I'm curious why you chose ASP over PHP? Any specific reasons, or are you just more comfortable with the VB syntax?
if i had a choice I would use perl, but since m$ owns the world, most proggramming classes require some sort of micrsoft language programming. Originally I was just hoping that I could use javascript server side because I didnt want to use vb. (ne reason why, just a personal preference). But I guess I am going to be forced, thansk for all of your help guys
john