如何使用经典的asp连接到SQL数据库?

时间:2022-06-01 13:05:17

Could someone please help solve this problem?

有人可以帮忙解决这个问题吗?

4 个解决方案

#1


5  

Here's a simple script that you can use:

这是一个可以使用的简单脚本:

<%

Dim conn

Set conn = Server.CreateObject("ADODB.Connection")

conn.Open "Provider=SQLOLEDB; Data Source = (local); Initial Catalog = Northwind; User Id = sa; Password="

If conn.errors.count = 0 Then

Response.Write "Connected OK"

End If

%>

And a def of the connection string members:

并且连接字符串成员的def:

  • Provider: The provider value tells ADO which data provider it should call to give us access to the data that we need. "SQLOLEDB" is the best provider to use for Microsoft SQL Server 2000 databases. If we left out the provider value, then ADO would automatically default to the "MSDASQL" provider, which is Microsoft’s OLEDB provider for ODBC compatible data repositories.
  • 提供者:提供者值告诉ADO它应该调用哪个数据提供者,以便我们访问我们需要的数据。 “SQLOLEDB”是用于Microsoft SQL Server 2000数据库的最佳提供程序。如果我们省略了提供者值,那么ADO将自动默认为“MSDASQL”提供程序,它是Microsoft的ODBC兼容数据存储库的OLEDB提供程序。
  • Data Source: The data source value tells our provider the IP Address or netbios name of the computer on which our database is available. In our example above, I have used the value "(local)". This value tells the provider that our database resides on the local machine, and to use local procedure calls instead of remote procedure calls. Using this data source value makes data access faster because database function calls are not bounced across the network and back to the SQL Server like they are normally.
  • 数据源:数据源值告诉我们的提供者我们的数据库可用的计算机的IP地址或netbios名称。在上面的例子中,我使用了值“(local)”。此值告诉提供程序我们的数据库驻留在本地计算机上,并使用本地过程调用而不是远程过程调用。使用此数据源值可以更快地访问数据,因为数据库函数调用不会像通常那样通过网络反弹回SQL Server。
  • Initial Catalog: The initial catalog value is just a fancy name for the database that the provider should connect us to by default.
  • 初始目录:初始目录值只是提供程序默认连接我们的数据库的一个奇特名称。
  • User Id: The login Id of the SQL Server user account that the provider should use during the authentication process.
  • 用户标识:提供程序在身份验证过程中应使用的SQL Server用户帐户的登录标识。
  • Password: The password of the SQL Server use account that the provider should use during the authentication process.
  • 密码:提供程序在身份验证过程中应使用的SQL Server使用帐户的密码。

Hope this helps!

希望这可以帮助!

#2


1  

<% 'database
dbserver = ""
dbcatalog = ""
dblogin = ""
dbpassword = ""
'connection string
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open = "Provider=SQLOLEDB; Data Source=" & dbserver & ";Initial Catalog=" & dbcatalog & ";User Id=" & dblogin & ";Password=" & dbpassword
 %>

this is the one i use. check out http://www.connectionstrings.com/ for a bunch more

这是我使用的那个。查看http://www.connectionstrings.com/了解更多信息

#3


0  

We can connect to database using 2 approaches: OleDB or DSN

我们可以使用两种方法连接到数据库:OleDB或DSN

Note: You need to create system DSN as shown below

注意:您需要创建系统DSN,如下所示

如何使用经典的asp连接到SQL数据库?

Session("Con") = "DSN=OL-SS;UID=test;PASSWORD=pwd"
Set objDbConnection = Server.CreateObject("ADODB.Connection")
objDbConnection.ConnectionTimeout = 0
objDbConnection.Open Session("Con")

#4


-1  

Interact with Database in classic Asp:

在经典Asp中与Database交互:

http://mygoldenmvc.blogspot.in/2015/12/crude-operations-in-classic-asp.html

http://mygoldenmvc.blogspot.in/2015/12/crude-operations-in-classic-asp.html

#1


5  

Here's a simple script that you can use:

这是一个可以使用的简单脚本:

<%

Dim conn

Set conn = Server.CreateObject("ADODB.Connection")

conn.Open "Provider=SQLOLEDB; Data Source = (local); Initial Catalog = Northwind; User Id = sa; Password="

If conn.errors.count = 0 Then

Response.Write "Connected OK"

End If

%>

And a def of the connection string members:

并且连接字符串成员的def:

  • Provider: The provider value tells ADO which data provider it should call to give us access to the data that we need. "SQLOLEDB" is the best provider to use for Microsoft SQL Server 2000 databases. If we left out the provider value, then ADO would automatically default to the "MSDASQL" provider, which is Microsoft’s OLEDB provider for ODBC compatible data repositories.
  • 提供者:提供者值告诉ADO它应该调用哪个数据提供者,以便我们访问我们需要的数据。 “SQLOLEDB”是用于Microsoft SQL Server 2000数据库的最佳提供程序。如果我们省略了提供者值,那么ADO将自动默认为“MSDASQL”提供程序,它是Microsoft的ODBC兼容数据存储库的OLEDB提供程序。
  • Data Source: The data source value tells our provider the IP Address or netbios name of the computer on which our database is available. In our example above, I have used the value "(local)". This value tells the provider that our database resides on the local machine, and to use local procedure calls instead of remote procedure calls. Using this data source value makes data access faster because database function calls are not bounced across the network and back to the SQL Server like they are normally.
  • 数据源:数据源值告诉我们的提供者我们的数据库可用的计算机的IP地址或netbios名称。在上面的例子中,我使用了值“(local)”。此值告诉提供程序我们的数据库驻留在本地计算机上,并使用本地过程调用而不是远程过程调用。使用此数据源值可以更快地访问数据,因为数据库函数调用不会像通常那样通过网络反弹回SQL Server。
  • Initial Catalog: The initial catalog value is just a fancy name for the database that the provider should connect us to by default.
  • 初始目录:初始目录值只是提供程序默认连接我们的数据库的一个奇特名称。
  • User Id: The login Id of the SQL Server user account that the provider should use during the authentication process.
  • 用户标识:提供程序在身份验证过程中应使用的SQL Server用户帐户的登录标识。
  • Password: The password of the SQL Server use account that the provider should use during the authentication process.
  • 密码:提供程序在身份验证过程中应使用的SQL Server使用帐户的密码。

Hope this helps!

希望这可以帮助!

#2


1  

<% 'database
dbserver = ""
dbcatalog = ""
dblogin = ""
dbpassword = ""
'connection string
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open = "Provider=SQLOLEDB; Data Source=" & dbserver & ";Initial Catalog=" & dbcatalog & ";User Id=" & dblogin & ";Password=" & dbpassword
 %>

this is the one i use. check out http://www.connectionstrings.com/ for a bunch more

这是我使用的那个。查看http://www.connectionstrings.com/了解更多信息

#3


0  

We can connect to database using 2 approaches: OleDB or DSN

我们可以使用两种方法连接到数据库:OleDB或DSN

Note: You need to create system DSN as shown below

注意:您需要创建系统DSN,如下所示

如何使用经典的asp连接到SQL数据库?

Session("Con") = "DSN=OL-SS;UID=test;PASSWORD=pwd"
Set objDbConnection = Server.CreateObject("ADODB.Connection")
objDbConnection.ConnectionTimeout = 0
objDbConnection.Open Session("Con")

#4


-1  

Interact with Database in classic Asp:

在经典Asp中与Database交互:

http://mygoldenmvc.blogspot.in/2015/12/crude-operations-in-classic-asp.html

http://mygoldenmvc.blogspot.in/2015/12/crude-operations-in-classic-asp.html