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