ASP include files and databases?

Networking/Security Forums -> Programming and More

Author: browolf PostPosted: Mon Nov 11, 2002 6:01 pm    Post subject: ASP include files and databases?
    ----
Hi,

i've been reading how good it is to use include files to open database connections in ASP.

but I'm wondering...

where do you close the database connection? do u even have to?
Doen an open database connection stay open if u change pages?

cheers

Andy

Author: ShaolinTigerLocation: Kuala Lumpur, Malaysia PostPosted: Mon Nov 11, 2002 6:20 pm    Post subject:
    ----
Yeh always use an include and a system DSN, but for the connection string rather than the connection itself.

Then you don't have to type the stupid code in each page.

You still have to open and close the connection as needed.

If you open a connection and don't close it when you change pages etc things get ugly.

Don't use the .inc extension if you use includes, use .asp Smile

My connection file would look something like this:

Code:
<%
' FileName="Connection_odbc_conn_dsn.htm"
' Type="ADO"
' HTTP="false"
' Catalog=""
' Schema=""
MM_sitename_STRING = "dsn=dsnstring;uid=;pw=;"
%>


Then to include it:

Code:
<!--#include file="Connections/filename.asp" -->


Then use the data by creating recordsets on each page and doing your biz on those.

Author: Jason PostPosted: Mon Nov 11, 2002 7:37 pm    Post subject:
    ----
A book worth looking at is SAM's "teach yourself ASP 2.0 in 21 Days".

Covers a bit of everything, a good start for the aspiring ASP Programmer.

J

Author: browolf PostPosted: Mon Nov 11, 2002 7:47 pm    Post subject:
    ----
i did loads of asp about 6 months ago.
I've been doing WSH recently, I seem to have forgotten how to do asp. heh Wink Crying or Very sad

i'd forgotten there was setting the connection and then doing open stuff. i remember using DSNless connections when i did it b4. It just seemed easier.

i'm just trying to figure out the best way to do it atm, with the least amount of work Wink

~ANdy

Author: chrisLocation: ~/security-forums PostPosted: Mon Nov 11, 2002 9:51 pm    Post subject:
    ----
SQL
Code:

Application("DataConnection") = "DRIVER={SQL Server};UID=user;PWD=pass;database=dbname;SERVER=localhost"


Access
Code:

Application("DataConnection") = "driver={Microsoft Access Driver (*.mdb)};dbq=" & replace(server.mappath("/"), "\db\") & "bleh.mdb"



Networking/Security Forums -> Programming and More


output generated using printer-friendly topic mod, All times are GMT + 2 Hours

Page 1 of 1

Powered by phpBB 2.0.x © 2001 phpBB Group