Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Help: Javascript Access Database Query

Hello,

I'm new to javascript, but am fairly proficient in ASP. I'm trying to autofill a text element in a form based on a prior text entry. I have a function that will input the text, but I'd like it to do a database query to determine the result. I tried to embed the ASP into the javascript code and I don't think it looks too good...or even works. How can i use JET to retreive a database value from an access database? Here's the code I have so far:

function dblookup()
{
<%
'Dimension variables
Dim conn 'Holds the Database Connection Object
Dim rs 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database

'Set an active connection to the Connection object using a DSN-less connection
cst = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db/sdi.mdb")

'Create an ADO connection object
set conn = CreateObject("ADODB.Connection")
'Create an ADO recordset object
Set rs = Server.CreateObject("ADODB.Recordset")
'Open connection object with existent (cst) connection type
conn.open cst
strSQL = "SELECT * FROM employeespulled WHERE empid='1'"
rs.open strSQL, conn
response.write "empid: " & rs("empid")
%>
alert "hello";

I hope I'm posting in the right forum; I don't want to repost in the javascript forum. Thanks in advance!

Panuvin
[1546 byte] By [panuvin] at [2007-11-11 6:47:36]