Full ASP Database code (ACCESS,MSSQL)

Source: Internet
Author: User
Tags chr mssql access database

Set Conn=server.createobject ("Adodb.connection")
Connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" &server.mappath ("/www.111cn.net/data.mdb")
Conn.Open ConnStr
%>


<%

Response.Buffer = True

Const msxmlversion= ". 3.0"
Const COOKIENAME = "Netpic"

Dim conn,connstr,datafile
Startime = Timer ()

' Modifiable settings One: ======================== defines a database category, 1 is a SQL database, and 0 is an Access database =============================
Const ISSQLDATABASE = 0
'============================================================================================================== ==
If issqldatabase = 1 Then
' must modify settings two: ========================sql Database Settings =============================================================
' SQL database connection parameters: Connection name (Sqllocalname) (Local locally, field IP), user name (sqlusername), user password (sqlpassword), database name (sqldatabasename)
Const SQLLOCALNAME = "(local)"
Const SQLUSERNAME = "SA"
Const SQLPASSWORD = "001225"
Const SQLDATABASENAME = "Photo"
'============================================================================================================== ==
datestring = Array ("GETDATE ()", "yyyy", "M", "D", "hh", "N", "s", "'")

ConnStr = "Driver={sql server};uid=" & sqlusername & ";p wd=" & SQLPassword & ";d atabase=" & Sqldatabas Ename & "server=" & Sqllocalname & ";
Else
' must modify settings three: ========================access Database Settings ==========================================================
DataFile = Server.MapPath ("data/#photo. mdb")
'============================================================================================================== ==
datestring = Array ("Now", "' yyyy '", "' m '", "' d '", "' H '", "' N '", "' s '", "#")

ConnStr = "Provider = Microsoft.jet.oledb.4.0;data Source =" & DataFile
End If

' On Error Resume Next
Set conn = Server.CreateObject ("Adodb.connection")
Conn.Open ConnStr
If Err Then
Err.Clear
Set conn = Nothing
Response.Write "Database connection error, please check the connection string. "
Response.End
End If

function checked (value1,value2)
Checked = "value=" &CHR (&VALUE2&CHR) (34)
If LCase (value1& "") =lcase (value2& "") then checked = checked & "Checked"
End Function

function selected (value1,value2)
Selected = "Value=" &CHR (&VALUE2&CHR) (34)
If LCase (value1& "") =lcase (value2& "") then selected = Selected & "Selected"
End Function
%>

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.