?? b?t ??u c?p nh?t d? li?u v�o File CSDL login.mdb, ch�ng ta c?n ph?i li�n k?t ??n t?p tin n�y. Tr??c khi li�n k?t, ch�ng ta c?n x�c l?p m?t s? c?u h�nh ???ng d?n(Server.MapPath), cho ph�p s? d?ng Parent Path truy xu?t ??n th? m?c b?t k? ch?a t?p tin CSDL.
Cho r?ng b?n ?� c�i IIS v�o Local Computer c?a b?n.
Cho r?ng b?n ?� t?o th? m?c sau ?�y tr�n m�y Local Computer c?a b?n:
C:\inetpub\myweb\mydomain\database. Trong ?� mydomain l� th? m?c g?c ?? ch?a c�c file .asp v� th? m?c database d�ng ?? ch?a t?p tin CSDL. ? ?�y ch�ng ta kh�ng ?? c?p ??n vi?c t?o Virtual Directory v� X�c l?p File Default.asp cho trang Web. V?n ?? ? ch? ?�i khi b?n kh�ng ??t th? m?c database v�o th? m?c g?c m� tr? ch�ng ??n m?t ???ng d?n n�o ?� c� th? l�n v�i SubFolder ho?c xu?ng v�i subfolder, khi ?� b?n ph?i d�ng c�c khai b�o nh? /subfolder/database ho?c ../../subfolder/database. N?u b?n kh�ng Enable Parent Path trong IIS, m� s? d?ng c�c k� t? nh? tr�n khi khai b�o ???ng d?n Server.MapPath, qu� tr�nh li�n k?t CSDL c� th? s? g?p ph?i l?i.
?? kh?c ph?c l?i n�y, b?n th?c hi?n c�c b??c sau:
T? Windows Desktop:
-Start --> Control Panel
-Doubl Click Administrative Tools.
-Double Click Internet Information Services.
-Click Local Computer
-Click Websites
-Click Default Websites
-Ch?n Mydomain --> Right Click ch?n Properties
-C?a s? mydomain properties m? ra nh? h�nh d??i:
Domain Properties
Trong c?a s? n�y Click Configuration, trong c?a s? m?i Application Configuration, click ch?n Options nh? h�nh d??i:
Application Configuration-Option-Enable parent Paths
Click OK, OK v� Exit IIS. Xong, t?t c? c�c c�ng ?o?n cho Datafile ho�n t?t. Ch�ng ta b?t ??u li�n k?t CSDL.
T?p tin li�n k?t CSDL:
T?p tin n�y s? ???c s? d?ng trong t?t c? c�c b�i h?c, v� ch�ng ta l?u v?i t�n file dbconnection.asp
C�ch 1:
<% Dim strDBPath, strCon
strDBPath=Server.MapPath("database/login.mdb")
strCon = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & strDbPath
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open strCon
Err.Clear
On Error Resume Next
%>
C�ch 2:
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.connectionstring = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" _ & Server.Mappath("database/login.mdb") & ";User Id=Administrator;Password=something;"
Conn.Open
%>
C�ch 3:
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0; DBQ=" _& Server.Mappath("database/login.mdb") & "User ID=Administrator;Password=something;"
Conn.Open
%>
N?u b?n kh�ng Set User ID v� password th� x�a ph?n n�y.
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0; DBQ=" _
& Server.Mappath("database/login.mdb") & ";"
Conn.Open
%>
Ch?n 1 c�ch t?t nh?t cho b?n, v?i b�i th?c h�nh n�y b?n n�n ch?n c�ch 1. L?u t?p tin tr�n v?i t�n dbconnection.asp v� ch�ng ta s?n s�ng cho c�c b�i k? ti?p.
Đăng nhận xét