Security Forums
Log in
FAQ
| Search
| Usergroups
| Profile
| Register
| RSS
| Posting Guidelines
| Recent Posts
View previous topic :: View next topic
Author
Message
browolf Trusted SF Member Joined: 19 Apr 2002 Posts: 1
Posted: 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
Back to top
ShaolinTiger Forum Fanatic Joined: 18 Apr 2002 Posts: 16777215 Location: Kuala Lumpur, Malaysia
Posted: 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
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.
Back to top
Jason Forum Fanatic Joined: 19 Sep 2002 Posts: 16777215
Posted: 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
Back to top
browolf Trusted SF Member Joined: 19 Apr 2002 Posts: 1
Posted: 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
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
~ANdy
Back to top
chris Forum Fanatic Joined: 18 Apr 2002 Posts: 16777201 Location: ~/security-forums
Posted: 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"
Back to top
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum