Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ASP + Libary+ Connection to DB

Posted on 1999-07-13
2
Medium Priority
?
211 Views
Last Modified: 2013-12-24
I want to put a function in the libary wich connect me to the DB.
Now I'am doing this in the same page where I send the SQL query.
The problem is that when I made a function with the Connection String, the page wich execute the question tell me that doesn't recognize the Conn object.
I send the code so maybe anybody can help me.

I create a Function in the libary with this connection code is all done with ASP...
<%
Function Conection()
  On error resume next
  Set Conn = Server.CreateObject("ADODB.Connection")
  Conn.Open "DSN=CaDistancia;UID=;PWD=;Database=CaDistancia"
  Conection = Conn
end Function
%>
In the page where I execute the query:
<%
Conn = Conection()
SQLStmt  ="SELECT * From Users"
SET Rs = Conn.Execute(SQLStmt)
%>

The ERROR IS Conn doesn`t exists.......
0
Comment
Question by:ORT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
jhappell earned 300 total points
ID: 1868076
The following should correct the problem.

<%
                Function Conection()
                  On error resume next
                  Set Conn = Server.CreateObject("ADODB.Connection")
                  Conn.Open "DSN=CaDistancia;UID=;PWD=;Database=CaDistancia"
                  SET Conection = Conn   'set function=ado connection
                end Function
%>

In the page where I execute the query:

<%
                SET Conn = Conection()    ' set variable = function
                SQLStmt  ="SELECT * From Users"
                set Rs = Conn.Execute(SQLStmt)
%>
0
 

Author Comment

by:ORT
ID: 1868077
Ok jHapell all works fine. I need a bit more help..
I try to define in the libarry a constant to use it in my pages.

In the library I put
myVar = "http:\\myplace.com\mydirecory\myfile.asp"

When I call the variable in the page where i execute the query the value is NULL.
response.write(myVar)

The porpouse of the var is to do this:

response.redirect(myVar)

Do I have to call the variable in a different way?
Thanks,
Fernando

0

Featured Post

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question