asp.web
<---------------------------------------------------conection.asp---------------------------------------------------------------->
<%
Dim objConnection
Sub openConnection()
Set objConnection=Server.CreateObject("ADODB.Connection")
Dim strConnection
strConnection="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("QLSV.mdb") & ";"
objConnection.open strConnection
End Sub
Sub closeConnection()
objConnection.Close
set objConnection=Nothing
End Sub
%>
------------------------------------------------------select.asp----------------------------------------------
<!-- #include file="Thuvien.asp" -->
<%
openConnection
set rs=Server.CreateObject("ADODB.Recordset")
strSQL ="Select * from tblSinhVien"
rs.Open strSQl,objConnection
%>
<table border=1 width="501" height="98">
<tr>
<td height="34" >Ma sinh vien</td>
<td height="34" align=center>Ho Va Ten</td>
<td height="34" >Ngay sinh</td>
<td height="34">Gioi tinh</td>
</tr>
<%
Do While Not Rs.EOF
%>
<tr>
<td width="121">
<%
Response.Write RS("MaSV")
%>
</td>
<td>
<%
Response.Write Rs("HoTen")
Response.Write (" ")
Response.Write RS("Ten")
%>
</td>
<td width="108">
<%
Response.Write RS("NgaySinh")
%>
</td>
<td width="53">
<%
If RS("GioiTinh")=True then
Response.Write "Nam"
Else
Response.Write "Nu"
End If
%>
</td>
<%
rs.MoveNext
Loop
%>
</tr>
</table>
<td><a href="Them.asp">Thêm sinh viên </a></td>
<br/>
<form name=frmDelete method=post action="DeleteStudent.asp">
<pre> Mã sinh viên: <input type=text name="txtMaSinhVien"></pre>
<input type=submit value="Delete">
</form>
------------------------------------------------------find.asp-----------------------------------
<html>
<head>
</head>
<body>
<%
Dim strMaSV
Dim strTenSV
strMaSV=Request.Form("txtMaSV")
strTenSV=Request.Form("txtTenSV")
%>
<!-- #include file="Thuvien.asp" -->
<%
openConnection
set rs=Server.CreateObject("ADODB.Recordset")
strSQL ="Select * from tblSinhVien Where MaSV ='" & strMaSV & "' And HoTen Like '" & strTenSV & "%'"
rs.Open strSQl,objConnection
%>
<!-- Where MaSV='" & strMaSV & "'" -->
<table border=1>
<tr>
<td>Ma sinh vien</td>
<td>Ho Va Ten</td>
<td>Ngay sinh</td>
<td>Gioi tinh</td>
</tr>
<%
Do While Not Rs.EOF
%>
<tr>
<td>
<%
Response.Write RS("MaSV")
%>
</td>
<td>
<%
Response.Write Rs("HoTen")
Response.Write (" ")
Response.Write RS("Ten")
%>
</td>
<td>
<%
Response.Write RS("NgaySinh")
%>
</td>
<td>
<%
If RS("MaSV")=-1 then
Response.Write "Nu"
Else
Response.Write "Nam"
End If
%>
</td>
<%
rs.MoveNext
Loop
%>
</tr>
</table>
</body>
</html>
------------------------------------------------------------------------delete.asp------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<!-- #include file="Thuvien.asp" -->
<%
Dim MaSinhVien
MaSinhVien=Request.Form("txtMaSinhVien")
openConnection
Dim strSQL
openConnection
set rs=Server.CreateObject("ADODB.Recordset")
strSQL ="Select * from tblSinhVien Where MaSV ='" & MaSinhVien & "'"
rs.Open strSQl,objConnection
If rs.EOF then
%>
<script language="javascript">
alert("Khong co sinh vien nao thoa man");
</script>
<%
Else
rs.Close
strSQL="Delete * From tblSinhVien Where MaSV='" & MaSinhVien & "'"
objConnection.execute strSQL
closeConnection()
Response.Redirect("Select.asp")
End IF
%>
</body>
</html>
------------------------------------------------------add.asp-------------------------------------------------------------
<html>
<body>
<!-- #include file="ThuVien.asp" -->
<%
openConnection()
Dim MaSinhVien,HoDem,Ten,NgaySinh,MaLop,GioiTinh
MaSinhVien=Request.Form("txtMaSinhVien")
HoDem=Request.Form("txtHoDem")
Ten=Request.Form("txtTen")
NgaySinh=Request.Form("txtNgaySinh")
Dim strSql
strSql="Insert into tblSinhVien(MaSV,HoTen,Ten,NgaySinh,MaLop) " & " Values ('" & MaSinhVien & "','" & HoDem & "','" & Ten & "','" & NgaySinh & "','" & MaLop & "')"
%>
<%
objConnection.execute strSQl
%>
<script language="javascript">
alert("Them thanh cong!")
</script>
<%
Response.Redirect("Select.asp")
%>
</body>
</html>
--------------------------------------------------------login.asp-----------------------------------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>login</title>
</head>
<body>
<%
dim user,pass
user=Request.Form("txtUser")
pass=Request.Form("txtPass")
if (user="") Or (pass="") then
%>
<script language="javascript">
alert("Ten hay Mat khau khong duoc de trong !")
history.back()
</script>
<%
else
if (user="Admin") and (pass="123") then
response.redirect("download.htm")
else
%>
<script language="javascript">
alert("Nhap sai User hoac Password !")
history.back()
</script>
<%
end if
end if
%>
</body>
</html>
Bạn đang đọc truyện trên: AzTruyen.Top