Although there are many introductions on the internet, I still have a lot of difficulty to connect. (To install IIS and SQL SERVER)
Create a new *.asp file and type
<%
Set Conn =server.createobject ("Adodb.connection")
Conn.Open "Provider=sqloledb;data source=local;uid =sa;pwd=******;d atabase=database-name "
%>
Comparison of Standard
Note that:
dataserver = "127.0.0.1"
dataserver = "(local)" are
available
connstr= "Driver={sql Server};server= "&dataserver&"; Uid= "&datauser&"; Pwd= "&databasepsw&";D atabase= "&databasename
connstr=" Provider=sqloledb;data source= (local); UID = "&datauser&;p wd=" &databasepsw& ";d atabase=" &databasename
Among them, provider behind the tube, according to write; source can be followed by IP address, where I use the local; SA is built in
User, it's the password you set up at the time of installation; The database is followed by the names of the databases you want to connect to, example: MyDatabase
(no extension required).
You can manipulate the database when you're done.
The following is a sample of a form that passes information to and from the database.
HTML file:
Copy Code code as follows:
<body>
<form name= "form" action= "*.asp" method= "POST" >
<input name= "name" type= "text" ><br>
<input name= "Password" type= "Password" ><br>
<input type= "Submit" >
</form>
</body>
ASP files: (the filename is the same as the *.asp after the action above, and is saved under the same path)
<%
Dim sql
sql = "SELECT * from Table-name"
set Conn=server.createobject ("Adodb.connection")
Conn.Open "provider=sqloledb;source=local;uid=sa;pwd=*******;d atabase=db-name"
set Rs=server.createobject (" Adodb.recordset ")
rs.open sql,conn,3,2
rs.addnew
rs (" name ") =request.form (" name ")
rs (" pwd ") = Request.Form ("Password")
rs.update
%>