ASP Connect SQL SERVER 2008 Method _ Application Tips

Source: Internet
Author: User

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
%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.