Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 12th, 2005, 07:55 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Default Easy but tricky for me... :(

Hello Guyz!!!

I`ve got the following lines of code...

<%
Dim oRSbg, pos, wh
dsnname= "anthem"
Set oRSbg=server.createobject("ADODB.recordset")
pos = "shadow"

sqlbg = "Select * from background WHERE position='" & pos & "' ORDER BY id DESC;"
oRSbg.open sqlbg, "DSN=anthem"
%>

What I want to do is to pass the variable of "dsnname" to the line where I open the DSN ("DSN=anthem"). SO... how do I have to do that?
Any ideas???

Thank you in advance!

       Vagelis!
 
Old January 12th, 2005, 02:46 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

There are two ways to do it:

1.

dsnname = "DSN=anthem"
oRSbg.open sqlbg, dsnname

IMO, this is the easiest way, as it allows you to change the DSN to an OleDb connection later.

2.
oRSbg.open sqlbg, "DSN=" & dsnname

This way you hard code DSN= and use the variable dsnname for the actual DSN name.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old January 13th, 2005, 06:24 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your reply!

I guess that I`m not going to use the DSN connection though... I think that I`ll use a DSN-less connection. What`s your opinion on that? I think that it`s a bit faster.
 
Old January 13th, 2005, 11:21 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yeah, OledDB is faster and more reliable.
But what's more important: it's easier to manage. When you need to copy code from one server to another, all you need to do is copy the file. There is no need to access the server and use the ODBC panel to set up a DNS....

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Tricky Queries balesh.mind SQL Server 2005 5 April 12th, 2008 10:29 PM
A tricky question mike_remember ASP.NET 1.0 and 1.1 Professional 3 October 27th, 2006 08:17 AM
Tricky Query BSkelding MySQL 5 August 31st, 2005 08:59 AM
Alright, here's a tricky one... Anubis Access VBA 14 November 19th, 2003 04:22 PM
Very tricky challenge 12th_Man SQL Language 3 June 20th, 2003 06:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.