無論是ASP PHP JSP 都需要連接數(shù)據(jù)庫代碼 在這里唐山網(wǎng)絡(luò)公司推薦幾款兼容性比較好的連接數(shù)據(jù)庫代碼!
ASP 連接ACCESS 代碼:
lujing="guanli/shuju/woai#asp#shuju.mdb"
set cn=server.CreateObject("adodb.connection")
cn.open"provider=microsoft.jet.oledb.4.0;data source="&server.MapPath(""&lujing&"")
asp 連接SQL代碼:
dim SqlLocalName,SqlUsername,SqlPassword,SqlDatabaseName,conn,connStr,db,Err_OpenDatabase
SqlLocalName ="(local)" '連接IP [ 本地用 (local) 外地用IP ]
SqlUsername ="sa" '用戶名
SqlPassword ="xxxx" '用戶密碼
SqlDatabaseName="315fangchan" '數(shù)據(jù)庫名
Set cn = Server.CreateObject("ADODB.connection")
connstr = "Provider=Sqloledb; User ID=" & SqlUsername & "; Password=" & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source=" & SqlLocalName & ";"
cn.Open connstr
asp 連接MYSQL不是最佳搭配所以這里就不寫代碼了!
php 和MYSQL 代碼如下:
<? session_start();
$hostname_conndigiBoard = "localhost";
$database_conndigiBoard = "greatwall_shop";
$username_conndigiBoard = "tgzy";
$password_conndigiBoard = "xxxx";
$conndigiBoard = mysql_pconnect($hostname_conndigiBoard, $username_conndigiBoard, $password_conndigiBoard) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db("wanlichangchengokk");
mysql_query("SET NAMES gbk");
?>
以上代碼都經(jīng)過唐山網(wǎng)絡(luò)公司測試 請大家挑選使用
本文來源:唐山長城網(wǎng)絡(luò) http://9899v.com