Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...It's extraordinarily refreshing to see truly expert advice without having to wade through hipper than thou attitude..."

Geography

Where in the world do Tek-Tips members come from?

How to access recordsets using javascriptHelpful Member! 

bryant89 (Programmer)
13 Dec 00 15:02
I need to see an example of how to access a recordset using javascript.  I can do it usint vb and dtc's but I have no idea when it comes to javascript

If anyone could give me a site to go to for examples or even an example they have that would be great
Helpful Member!  palbano (Programmer)
13 Dec 00 18:10
Here is one way that works, there are any number of different techniques that you can use to work with ADODB Objects.

var conn = Server.CreateObject("ADODB.Connection");
conn.Open("dsn=ftwebdocs");
var rs = Server.CreateObject("ADODB.Recordset");
rs.Open("select Title, FlashDate, Name, DocTypeDI from mytable", conn, 1,3,1);

while( !rs.EOF){
  Response.Write( rs("Title") + ": " + rs("Name") + "<br>");
  rs.MoveNext();
}

rs.Close();
conn.Close()
rs = null;
conn = null;

Hope this helps
-pete
bryant89 (Programmer)
14 Dec 00 10:51
Right on, I will try this out.  I have a few questions though about what parameters I have to change I have highlited things I need clarification on.


var conn = Server.CreateObject("ADODB.Connection");
conn.Open("dsn=ftwebdocs");
var rs = Server.CreateObject("ADODB.Recordset");
rs.Open("select Title, FlashDate, Name, DocTypeDI from mytable", conn, 1,3,1);

while( !rs.EOF){
  Response.Write( rs("Title") + ": " + rs("Name") + "<br>");
  rs.MoveNext();
}

rs.Close();
conn.Close()
rs = null;
conn = null;


The reason I need to loop through a recordset is to get the directory path of certain images that are stored in fields in the table. So each time I loop through the recordset I need to save the value retrieved into a seperate variable.  Then pass these variables to a seperate function to set my source values of 3 different images that are retrieved from the recordset. I hope this makes sense.

I have to add again that I appreciate all of your help
palbano (Programmer)
14 Dec 00 11:15
> conn.Open("dsn=ftwebdocs");

DSN = Data Source Name. Are you familiar with them? You use the OLE32 Control Panel Applet to create them. They hold the connection information to your data source.

> get the directory path of certain images that are stored in fields in the table

You should be able to generate a SQL statement that will retrieve only the rows contianing the images of interest. This should keep you from having to 'search' through the returned recordset.

The in your while loop just replace:
Response.Write( rs("Title") + ": " + rs("Name") + "<br>");

with whatever HTML you need, OR even use inline ASP replacement style code, i.e.:

<%
while( !rs.EOF){
%>
<div><%=rs("Title")%><span class="foo"><%=rs("Name")%></span></div>

<%
  rs.MoveNext();
}
%>

Hope this helps
-pete
bryant89 (Programmer)
14 Dec 00 11:30
I cant use ASP replacement code within javascript tags

ie
<script language="JavaScript1.2">
// slide show
function reapply()
{
    setTimeout("slideit()",2000)
    return true
}
window.onerror=reapply
</script>
<script language="JavaScript1.1">
<!--
var image1=new Image()
image1.src="<%../MemberImages/ProjPics/13-5-1.jpg %>"
var image2=new Image()
image2.src="../MemberImages/ProjPics/13-5-2.jpg"
var image3=new Image()
image3.src="../MemberImages/ProjPics/13-5-3.jpg"
//-->
</script>

the asp style is not recognized.  Do you have an email address I could get from you or a chat program that u run.  So I can explain to you better what I am trying to do.
palbano (Programmer)
14 Dec 00 11:39
You are missing the 'equal' siqn and you need a variable or object inside the ASP replacment statement:

<% var sImageOne = ... // whatever %>

image1.src="<%=sImageOne%>"


pete@albano.reno.nv.us
-pete

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close