+ -
当前位置:首页 → 问答吧 → 在ASP,如何将读取数据库的代码写到一个文本文件被调用?

在ASP,如何将读取数据库的代码写到一个文本文件被调用?

时间:2011-11-30

来源:互联网

有许多ASP文件,都要用到打开SQL SERVER数据库,怎样写进一个文件被这些ASP文件调用呢?

作者: bwe2009   发布时间: 2011-11-30

1 global.asa 中
Application("str") = "连接串"
ASP中
Set conn = CreateObject("ADODB.Connection")
conn.Open Application("str")

2 写成 文件conn.asp
str = "连接串"
ASP中 <!--#include virtual="/inc/conn.asp" -->
Set conn = CreateObject("ADODB.Connection")
conn.Open str

连接打开的代码也可以在 conn.asp中,不过还是只保存连接串比较好。


作者: hookee   发布时间: 2011-11-30