Page: 1 การพัฒนาโปรแกรมประยุกต์บนเว็บ อ. บุรินทร์ รุจจนพันธุ์.. ปรับปรุง 23 มิถุนายน 2550 Data Updating by ASP มหาวิทยาลัยโยนก จังหวัด ลำปาง ศูนย์กลางความรู้และภูมิปัญญา แผ่นดิน
Page: 2 DSNLess + !recordset <% set c = server.createobject("adodb.connection") c = "driver={microsoft access driver (*.mdb)}; " c = c & "dbq=" & server.mappath("dthai97.mdb") sql = "select * from tbthai" set rs = c.execute(sql) do while not rs.eof response.write(rs("fid") & " ") rs.MoveNext loop c.close set rs = nothing set c = nothing %> แฟ้มข้อมูลทดสอบจาก
Page: 3 Insert (1/2) <% set c = server.createobject("adodb.connection") c = "driver={microsoft access driver (*.mdb)}; " c = c & "dbq=" & server.mappath("dthai97.mdb") sql=" insert into tbthai(fid,fname,fsalary) select " sql=sql&" "& request.form("fid") &" as fid, " sql=sql&" '"& request.form("fname") &"' as fname, " sql=sql&" "& request.form("fsalary") &" as fsalary" set rs = c.execute(sql) c.close %>
Page: 4 Insert (2/2) <% set c = server.createobject("adodb.connection") c = "driver={microsoft access driver (*.mdb)}; " c = c & "dbq=" & server.mappath("dthai97.mdb") sql= "insert into tbthai(fid,fname,fsalary)" sql= sql & "values (" sql= sql & request.form("fid") & "," sql= sql & "'" & request.form("fname") & "'," sql= sql & request.form("fsalary") & ")" set rs = c.execute(sql) c.close %>
Page: 5 Delete <% set c = server.createobject("adodb.connection") c = "driver={microsoft access driver (*.mdb)}; " c = c & "dbq=" & server.mappath("dthai97.mdb") sql= "delete from tbthai where" sql= sql & " fid=" & request.form("fid") set rs = c.execute(sql) c.close %>
Page: 6 Update <% set c = server.createobject("adodb.connection") c = "driver={microsoft access driver (*.mdb)}; " c = c & "dbq=" & server.mappath("dthai97.mdb") sql= "update tbthai set fname='" sql= sql & request.form("fname") & "' where" sql= sql & " fid=" & request.form("fid") set rs = c.execute(sql) c.close %>