Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 25th, 2005, 08:28 PM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to howbadboy
Default Parameterised Access Query in javascript

HI,

I'm new to asp/javascript and am strugglling to get to grips with using a form input as an input to a stored procedure in Access.

I've seen a lot of code for VbScript and Ole Db (i'm using odbc) and am still confused!!

Basically I have the following code:

<%@LANGUAGE="JAVASCRIPT"%>
</head>
<body>
<%

    var dbConn = Server.CreateObject("ADODB.Connection");
    dbConn.Open("custconn");

    var dbComm = Server.CreateObject("ADODB.Command");

    dbComm.commandtext = "cityQuery";
    dbComm.commandtype = adCmdStoredProc;

    var objParam = dbComm.CreateParameter("City", adVarChar, adParamInput);
    dbComm.Parameters.Append(dbComm);
    objCommand.Parameters("City") = "London";

    dbComm.activeconnection = dbConn;
    var rSet = Server.CreateObject("ADODB.Recordset");
    dbComm.execute();
%>
</body>
</html>

I'm looking to return all records whose city value is 'London'
I'm trying to kinda copy VBScript examples but really am coming up against the wall...as i said...this is all pretty new territory to me.

Does anyone have some url's that will go through this on a pretty basic or simple level..

thanks

alan

Reply With Quote
  #2 (permalink)  
Old February 26th, 2005, 07:49 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Please don't post the same question in two forums.

Assuming your connection succeeds and you have defined the adVarChar etc, normally via an include file, then the only thing that jumps out at me is:
Code:
objCommand.Parameters("City") = "London";
JavaScript doesn't understand default object properties so you need:
Code:
objCommand.Parameters("City").value = "London";
Remember this when you try to output using the recordset:
Code:
//var rSet = Server.CreateObject("ADODB.Recordset"); NOT NEEDED
var rSet =  dbComm.execute();
if (rSet.EOF && rSet.BOF)
{
  //No records
}
else
{
  while (!rSet.EOF)
  {
    Response.Write(rSet.fields(0).value + "<br>");
    rSet.moveNext();
  }
}
rSet.close();
--

Joe (Microsoft MVP - XML)
Reply With Quote
  #3 (permalink)  
Old February 26th, 2005, 12:39 PM
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to howbadboy
Default

cheers for the quick reply...and apologies for the double post...
hopefully this will do the trick
thanks again

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript Access Database Query panuvin Javascript How-To 28 May 9th, 2008 01:53 PM
Parameterised Input stored procedure fdtoo SQL Server 2000 0 November 7th, 2007 07:11 AM
Query string to a external javascript file anujrathi ASP.NET 1.0 and 1.1 Professional 1 November 4th, 2006 01:26 AM
Open a Parameterised Query to screen using code vbark Access VBA 2 June 5th, 2006 05:46 PM
how to call xml using javascript then query Apocolypse2005 Javascript 0 January 11th, 2006 10:53 AM



All times are GMT -4. The time now is 11:38 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.