每日小结(2)

摘要

  • 在 win10 中开启 IIS 服务器并支持 .asp 文件的解析
  • 在 IIS 7 上使用 asp 连接 SQLite 数据库

在 win10 中开启 IIS 服务器并支持 .asp 文件的解析

系统:win10 amd64 1803

开启 IIS 服务

打开控制面板 => 程序与功能 => 启用或关闭 Windows 功能,找到 Internet Information Services 项:

然后在浏览器中输入 localhost 就可以看到默认界面了。

使 IIS 支持 .asp 文件的解析

展开上图中的 “应用程序开发功能” 项,选中 ASP 和 ISAPI 扩展这两项:

将 C:\inetpub\wwwroot\index.htm 文件重命名为 index.asp,即改为 asp 文件,即可使用 asp 的语法。

在 IIS 中添加默认文档 index.asp

或者在网站根目录添加一个 web.config 文件:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <add value="index.asp" />
                <add value="index.aspx" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>

参考

  1. https://docs.microsoft.com/en-us/iis/application-frameworks/running-classic-asp-applications-on-iis-7-and-iis-8/classic-asp-not-installed-by-default-on-iis

在 IIS 7 上使用 asp 连接 SQLite 数据库

  1. 打开 “ODBC 数据源管理器”,在开始中搜索:

或者使用 win + R 创建任务: %windir%\system32\odbcad32.exe :

  1. 添加系统 DSN:

点击 添加,选择合适的 SQLite 驱动,这里我用的是 Devart ODBC Driver for SQLite,点击 完成

Data Source Name 这一栏可以任意填,但是 在 asp 程序中填写 connection string 时要与这里的对应

Database 这一栏定位到 SQLite 数据库中,点击 OK,数据源就设置好了。

  1. 接下来要修改 connection string:
' following connection string is not valid on IIS 7
'connString = "DRIVER=SQLite3 ODBC Driver;Database=" & dbpath & ";LongNames=0;Timeout=1000;NoTXN=0;SyncPragma=NORMAL;StepAPI=0;"
' using Driver: Devart ODBC Driver for SQLite, following connection string works well on IIS 7
connString = "Driver=SQLite3 ODBC Driver;Data Source=" & "testdb" &"; Version=3;Legacy Format=True;" 

on error resume next
conn.Open connString

注意上面的 connString 中的 Data Source 项要和上面设置 DSN 中 Data Source Name的对应。

  1. 测试服务器,可以正常读取数据库

猜你喜欢

转载自www.cnblogs.com/brifuture/p/9650078.html