以下是ASP常见连接数据库的字符串写法,记得收藏留存哦。
1.Access 2007 连接字符串:
strConnect = "Provider=Microsoft.ACE.OLEDB.12.0;Mode=Share Exclusive;Data Source=C:\MyDatabase.mdb;"
2.Access 2007 连接字符串(使用相对路径):
strConnect = "Provider=Microsoft.ACE.OLEDB.12.0;Mode=Share Exclusive;Data Source=.\MyDatabase.mdb;"
3.SQL Server 连接字符串:
strConnect = "Provider=SQLOLEDB;Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password;"
4.MySQL 连接字符串:
strConnect = "Driver={MySQL ODBC 5.1 Driver};Server=ServerName;Database=DatabaseName;User=UserName;Password=Password;Option=3;"
5.Oracle 连接字符串:
strConnect = "Provider=OraOLEDB.Oracle;Data Source=ServerName;User ID=UserName;Password=Password;"
请注意,具体的连接字符串取决于你所连接的数据库类型和相关配置。