View Single Post
  #11 (permalink)  
Old August 23rd, 2007, 10:25 PM
ncarney ncarney is offline
Registered User
 
Join Date: Aug 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm experiencing the same "'Server' is undefined" error when calling the Server object using javascript. However, it only gives me the error when I declare javascript in the <script> tag, not when javascript is declared as the default for the page. I need to be able to declare it in the <script> tag since I am using both javascript and vbscript in the application.
---------------------------------
The following runs without error:

<%@ LANGUAGE = "JavaScript"%>
<HTML>
<BODY>

<%
var conn = Server.CreateObject("ADODB.Connection");
var rs;
var dbPath = new String("PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=c:/inetpub/testsite/admin/db/db.mdb");
conn.Open(dbPath);
rs = conn.Execute("select * from products");
%>

</BODY>
</HTML>
-----------------------
The following results in "Error: 'Server' is undefined" at the Server.CreateObject line:

<HTML>
<BODY>

<script type="text/javascript">
var conn = Server.CreateObject("ADODB.Connection");
var rs;
var dbPath = new String("PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=c:/inetpub/testsite/admin/db/db.mdb");
conn.Open(dbPath);
rs = conn.Execute("select * from products");
</script>

</BODY>
</HTML>



Reply With Quote