Reply
read ms access database and store in javascript variable
Old 05-25-2005, 07:57 PM read ms access database and store in javascript variable
Junior Talker

Posts: 2
I want to read price from a ms access database and store it in a javascript variable to be used for calculations.
Any help appreciated,
Thanks,
Niko


This is my test code:

<html>
<head>
<title>test</title>
<!-- Read database -->
<!--#include file="include/testg1/HG1DK121I.asp" -->

<script language="javascript">
<!-- store price in javascript variable -->
<!-- this code causes a blank page -->
<!-- leave it out and I get vaiable xxx = 666 -->
var c1D41=( <%= HG1DK121I %> );
<!-- dummy javascript variable -->
var xxx=(666)
</script>

<%
'Reset server objects
HG1DK121I.Close
Set HG1DK121I = Nothing
Set adoConHG1DK121I = Nothing
%>
</head>


<body>

<script language="javascript">
<!-- print dummy javascript variable -->
document.write('vaiable xxx = ' + xxx);
<!-- print database price -->
document.write(c1D41);
</script>

</body>
</html>


----------------

This is the include file HG1DK121I.asp

<%
'Dimension variables
Dim adoConHG1DK121I 'Holds the Database Connection Object
Dim HG1DK121I 'Holds the recordset for the records in the database
Dim strSQLHG1DK121I 'Holds the SQL query to query the database

'Create an ADO connection object
Set adoConHG1DK121I = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoConHG1DK121I.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/Price.mdb")

'Create an ADO recordset object
Set HG1DK121I = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQLHG1DK121I = "SELECT Product.Code, Product.System, Product.Group, Product.Product, Product.Price FROM Product WHERE Code='HG1DK121I'"

'Open the recordset with the SQL query
HG1DK121I.Open strSQLHG1DK121I, adoConHG1DK121I

%>


--------------
Niko2005 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Reply     « Reply to read ms access database and store in javascript variable
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.10973 seconds with 12 queries