ASP and ACCESS programming note
1. Open access database (without need of ODBC DSN)
2. Read from database
3. Write into database
4. Edit existing record
-movenext until record to edit
-same with write, but without objRS.AddNew
5. Delete record
-movenext until record to edit
-objRS.Delete
<%
DIM objConn
Set objConn=Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("/mydbase/DBPHONE.mdb") & ";"
objConn.Open
%>
2. Read from database
<%
DIM objRS, tSQL
Set objRS=Server.CreateObject("ADODB.Recordset")
tSQL="SELECT * FROM TPHONE"
objRS.Open tSQL,objConn
Do While Not objRS.EOF
response.write (ObjRS("NAME") & "-" & ObjRS("PHONENO")
objRS.movenext
Loop
objRS.Close
objConn.Close
%>
3. Write into database
<%
DIM objRS, tSQL
Set objRS=Server.CreateObject("ADODB.Recordset")
objRS.CursorType=2
objRS.LockType=3
tSQL="SELECT * FROM TPHONE"
objRS.Open tSQL,objConn
objRS.AddNew
objRS("NAME")="Diana Naim"
objRS("PHONENO")="03-2300 1234"
objRS.Update
objRS.Close
objConn.Close
%>
4. Edit existing record
-movenext until record to edit
-same with write, but without objRS.AddNew
5. Delete record
-movenext until record to edit
-objRS.Delete
0 Comments:
Post a Comment
<< Home