Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database Reading/Writing

Status
Not open for further replies.

sleuth

Programmer
Jan 12, 2001
134
US

OK, I know that this can be done in javascript. Will someone please give a code that can append to a database, and another function that will read the first line and print that out of the same database as an example.

I know it's a lot to ask but I can't find anything on it and the only way I can learn is to play with the code. I'm a perl programmer so javascript is similar to me but I'm still real rusty.

Thank You so Very Much!!!

Sleuth
 

Thanks but I'm on a linux server and can't run ASP, I need it in javascript.

Sleuth
 
database is SERVER side whereas javascript is CLIENT side
you need to use a server side langage
 
both javascript and jscript have server-side edititions... to use it you must have IIS or Netscape Enterprise Server jared@aauser.com
 
right jaredn, but i didn't say about the server side jscript because it's not that often that you can access & configure the server to put your server side scripts ... more often it's easier to use some kind of cgi langage ... well maybe i'm wrong ?
 
Not sure, I use server-side jscript (with ASP) every day... ;-) jared@aauser.com
 
jaredn really?????
I do have iis, is that enough to do that?
Can u give me an example?
It can solve some problems u know.
Thanks
 
save a file as .asp

put this first in the file:

<%@ Language=&quot;JScript&quot; %>

then try this:

<%=new Date()%>

somewhere....i'm not sure what you have to set up, but I don't think it's complicated jared@aauser.com
 
But it has nothing to do with database right?
I thought u ment it's possible to work with the database
using jscript.
Is it? If it is, I'll be happy to have an example please.
Thanks. :)

P.s - what does it mean that I'm in the &quot;top members&quot; in this forum?
 
<%
queryvar = Request.QueryString(&quot;ccval&quot;)

//make connection
aconn = Server.CreateObject('ADODB.connection');
aconn.Open(&quot;DSN=ACUADMIN_fampc;UID=xxx;PWD=xxx;&quot;);

//define query and execute
sqlbeg = &quot;SELECT * FROM fampc WHERE phone='&quot;+queryvar+&quot;'&quot;;
recset = aconn.Execute(sqlbeg);
queryvar = recset('code')
%>

<input type=&quot;text&quot; value=&quot;<%=recset('name')%>&quot;>

this will take a value from the table and stick it into the text field
jared@aauser.com
 
There's a big divide between server-side and client-side Javascript, and I think this is confusing to alot of people. They are not the same, and they can't even talk directly to each other, so server-side Javascript is just what it is: another scripting language, with no special advantages over PHP, JSP, ASP/VB, etc...

It's not until you get into Java or ActiveX that you can have client-server state communication.

Sleuth, If you are on a Linux server, I don't think there is a server-side javascript interpreter, yet. I remember some talk of an attempt to do it with Perl (called Fesi, I think), but I don't think its a very mature system. (This was mentioned in Professional Javascript by Wrox Press).

Client-side Javascript won't do this, and even if there is a server-side Javascript for Linux, I doubt it has a good database access layer. Perl::DBI or PHP are much better choices for this. What database are you using? If you know Perl, why on Earth do you need Javascript for this? (sorry to throw so much at you at once ;-) )
 
I think there is an ASP module for Apache (???) If you know javascript, what better language to use for data access on the server? I use it constanly and haven't come across something I couldn't achieve with a database... jared@aauser.com
 
there's a module for apache that allows for perlscript to be used as asp. adam@aauser.com
 

Javascript can too manipulate files on the server. I just need some examples that are better than the ones I've read.

Sleuth
 
the only way i can think of to have javascript edit files on a linux server is if you are running netscape enterprise server. then you can use Server-Side JavaScript. if you're not running NES, then you 're out of luck. adam@aauser.com
 

Ok, I'm probably wrong, but work with me on this, I found this so far,


<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
var TristateFalse = 0;
var ForWriting = 2;
myActiveXObject = new ActiveXObject(&quot;Scripting.FileSystemObject&quot;);
myActiveXObject.CreateTextFile(&quot;c:\\test.txt&quot;);
file = myActiveXObject.GetFile(&quot;c:\\test.txt&quot;);
text = file.OpenAsTextStream(ForWriting, TristateFalse);
text.Write(&quot;This is a test&quot;);
text.Close();
// -->
</SCRIPT>

Now, on my hardrive this works. On the web it doesn't, so I figured it won't write to my drive from the web, but it won't write to the server either. Which makes sense. But if you have front page put that in it and preview the page. Then see if the file is there. Tell me is it possible to get that to work on the server? If not, then what will? I can't use ASP, I'm on Linux, what's Jscript, and would vbscript work?

Thanks,

Sleuth
 
vbscript is proprietary... microsoft only, as is jscript. what you are using is jscript... client-side jscript at that... which will only work on the clients computer, if they are using IE. adam@aauser.com
 
if you're running a linux and apache, why not use perl? there are modules for apache to run perl as asp, if you don't want to write a script. you're better off using perl or php to modify files on the server using linux. adam@aauser.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top