ASP connection database and simple crud

Source: Internet
Author: User

<%

Dim Db,connstr,conn,sql,rs

' Database file name

db = "Test.mdb"

' Database connection string

ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath (DB)

' Create an instance of the connection connection object

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

' Call the Open method of Conn to turn on the connection

Conn.Open ConnStr

' SQL statement tb_user as table name

' Modify sql = ' UPDATE tb_user Set username= ' test1 ' where userid=1 '

' Remove sql = ' Delete from Tb_user where userid=1 '

' Add sql = ' INSERT into Tb_user (username,sex) VALUES (' test1 ', ' female ') "

Sql= "Select username from tb_user where userid=1" ' Query

' Create an object instance of the Adodb.recordset data record RS

Set rs = Server.CreateObject ("ADODB". Recordset ")

' Execute SQL statement to get recordset

Rs. Open sql,conn,1,1

' Determine if there is data, there is output, no hint

If not Rs. EOF Then

Response.Write (RS ("username"))

Else

Response.Write ("no user")

%>

Ps:

Set rs = Server.CreateObject ("Adodb.recordset")

Rs.Open Sql,conn

Can be replaced with the

Set Rs=conn.execute (SQL)

Same effect

ASP connection database and simple crud

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.