Could someone please help solve this problem?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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:
- 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.
- 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.
- 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.
- Password: The password of the SQL Server use account that the provider should use during the authentication process.
Hope this helps!
回答2:
<% '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
回答3:
We can connect to database using 2 approaches: OleDB or DSN
Note: You need to create system DSN as shown below
Session("Con") = "DSN=OL-SS;UID=test;PASSWORD=pwd"
Set objDbConnection = Server.CreateObject("ADODB.Connection")
objDbConnection.ConnectionTimeout = 0
objDbConnection.Open Session("Con")
回答4:
Interact with Database in classic Asp:
http://mygoldenmvc.blogspot.in/2015/12/crude-operations-in-classic-asp.html