Connecting to the database using ASP and determining whether the database is successful

Source: Internet
Author: User

Connecting to the database using ASP and determining whether the database is successful
Posted on 22:12:00
0
It is recommended that the code below ASP be used recently to connect to the ACCESS database in the specified directory.
<%
Set conn = server. Createobject ("ADODB. Connection ")
'Conn. Open "provider = Microsoft. Jet. oledb.4.0; Data Source =" & server. mappath ("../databases/DB. mdb") 'connect to the database in the new version
Conn. open "driver = {Microsoft Access Driver (*. MDB)}; DBQ = "& server. mappath (".. /databases/DB. mdb ") 'old version connected to the database
%>

When the SQL sentence is successfully completed, you can determine the value returned by the conn.exe cut (SQL) language name:
<%
On Error resume next
Set rs1_conn.exe cute (SQL) 'SQL is the specific SQL Execution statement
Dim errmsg
If err. Number = 0 then
Errmsg = "database operation successful! "
Else
Errmsg = "database operation failed! "
End if
%>

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.