|
|
|
ช่วยดูโค้ดแก้ไขให้หน่อยค่ะคือมันเชื่อมต่อกับฐานข้อมูลไม่ได้สักที |
|
|
|
|
|
|
|
e1.asp.
*****************************************************
<html>
<body>
<form name="form1" method="post" action="de1.asp">
ค้นหาจากรหัสนักศึกษา
<input type="text" name="keyword" value="<%=Request.Form("keyword")%>">
<input type="submit" name="Submit" value="ค้นหา">
</form>
<%
if Request.Form("keyword")="" then
Response.write("<br>ยังไม่แสดงข้อมูลกรุณาทำการใส่รหัสนักศึกษาที่ต้องการลบ<hr>")
else
Set Conn=Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("database1.mdb"),"" , ""
sql ="Select * From student where studid like '%"&Request.Form("keyword")&"%'"
Set Rs = Conn.Execute(sql)
If Rs.EOF Then
%>
ไม่พบรหัสนี้ค่ะ
<span class="style4"><strong> ! </strong></span>
<%Else%>
<table border="1">
<tr bgcolor="#00FFFF">
<td width="140"><div align="center"><strong>รหัสนักศึกษา</strong></div></td>
<td width="218"><div align="center"><span class="style3">ชื่อนักศึกษา</span></div></td>
<td width="113"><div align="center"><span class="style3">ระดับการศึกษา</span></div></td>
<td width="74"><div align="center"><span class="style3">ห้อง</span></div></td>
<td width="129"><div align="center"><span class="style3">แผนก</span></div></td>
<td width="58"><div align="center"><span class="style3">ลบ</span></div></td>
</tr>
<% While Not Rs.EOF%>
<tr>
<td><%= Rs("studid")%></td>
<td><%= Rs("studname")%></td>
<td><%= Rs("level")%></td>
<td><%= Rs("studroom")%></td>
<td><%= Rs("braid")%></td>
<td><a href="de2.asp?id=<%=Rs("studid")%>">Delete</a></td>
</tr>
<% Rs.MoveNext
Wend
Rs.Close
Conn.Close
End If
%>
</table>
<%
end if
%>
</body>
</html>
e2.asp
*********************************************************
<html>
<head>
<title>แก้ไขข้อมูล</title>
<style type="text/css">
<!--
.style3 { color: #0000FF;
font-weight: bold;
}
.style5 {
font-size: 24px;
color: #990000;
font-weight: bold;
}
body,td,th {
font-family: MS Sans Serif;
font-size: 16px;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874"><body bgcolor="#FFFFFF">
<form name="form1" method="post" action="e3.asp">
<div align="center"><span class="style5">แก้ไขข้อมูลนักเรียน-นักศึกษา</span><br>
<%
Set Conn=Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("database1.mdb"),"" , ""
'หรือจะใช้เป็น Conn.Open "product","",""
sql ="Select * From student where studid=" & Request.QueryString("studid")
'Set Rs = Conn.Execute(sql)
%>
<input type="hidden" name="studid" value="<%=Rs("studid")%>">
<br>
</div>
<table width="579" border="1" align="center">
<tr>
<td width="118"><div align="center" class="style3">รหัสนักศึกษา</div></td>
<td width="445"><input name="studid" type="text" value="<%=rs("studid")%>" size="20" maxlength="10"> </td>
</tr>
<tr>
<td><div align="center" class="style3">ชื่อนักศึกษา</div></td>
<td><input name="studname" type="text" value="<%=rs("studname")%>" size="50" maxlength="50">
<tr>
<td><div align="center" class="style3">ระดับการศึกษา</div></td>
<td><input name="level" type="text" value="<%=rs("level")%>" size="20" maxlength="5"></td>
</tr>
<tr>
<td><div align="center" class="style3">ห้อง</div></td>
<td><input name="studroom" type="text" value="<%=rs("studroom")%>" size="10" maxlength="5"></td>
</tr>
<tr>
<td><div align="center" class="style3">แผนก</div></td>
<td><input name="?braid" type="text" value="<%=rs("braid")%>" size="50" maxlength="50"></td>
</tr>
<tr>
<td><div align="center" class="style3">ที่อยู่</div></td>
<td><input name="studadd" type="text" value="<%=rs("studadd")%>" size="60" maxlength="60"></td>
</tr>
<tr>
<td><div align="center" class="style3">อำเภอ</div></td>
<td><input name="sdis" type="text" value="<%=rs("sdis")%>" size="30" maxlength="30"></td>
</tr>
<tr>
<td><div align="center" class="style3">จังหวัด</div></td>
<td><input name="spro" type="text" value="<%=rs("spro")%>" size="30"></td>
</tr>
<tr>
<td><div align="center" class="style3">รหัสไปรษณีย์</div></td>
<td><input name="zip" type="text" value="<%=rs("zip")%>" size="10" maxlength="5"></td>
</tr>
<tr>
<td><div align="center" class="style3">อาจารย์ที่ปรึกษา</div></td>
<td><input name="techid" type="text" id="techid" value="<%=rs("techid")%>" size="50" maxlength="50"></td>
</tr>
<td><div align="center" class="style3">username</div></td>
<td><input name="username" type="text" value="<%=rs("username")%>" size="30" maxlength="10"></td>
</tr>
<td><div align="center" class="style3">Password</div></td>
<td><input name="password" type="text" value="<%=rs("password")%>" size="30" maxlength="4" /></td>
</tr>
</table>
<div align="center"><br>
<input type="submit" name="Submit2" value="Edit">
<input type="reset" name="Reset" value="cancle">
</div>
</form>
</body>
</html>
e3.asp
*****************************
<style type="text/css">
<!--
body,td,th {
font-size: 16px;
}
-->
</style><%
Set Conn=Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("db/database1.mdb"),"" , ""
sql ="Select * From student where studid="&Request.Form("studid")
Set RS =Server.CreateObject("ADODB.Recordset")
RS.open Sql,Conn,1,3
Rs("studname") = Request.Form("studname")
Rs("level") = Request.Form("level")
Rs("studroom") = Request.Form("studroom")
Rs("braid") = Request.Form("braid")
Rs("studadd") = Request.Form("studadd")
Rs("sdis") = Request.Form("sdis")
Rs("spro") = Request.Form("spro")
Rs("zip") = Request.Form("zip")
Rs("techid") = Request.Form("techid")
Rs("username") = Request.Form("username")
Rs("password") = Request.Form("password")
Rs.Update
Conn.Close
response.write("แก้ไขเรียบร้อยแบล้วค่ะ")
%>
**** ,มันชอบ Error ตรงบรรทัด ที่พิมพ์ว่า 'Set Rs = Conn.Execute(sql) ***********
ถ้าใครรู้ก็ช่วนหน่อยนะค่ะ
ขอบคุณค่ะ
Tag : - - - -
|
|
|
|
|
|
Date :
29 ม.ค. 2551 14:44:29 |
By :
น้องแพร |
View :
1356 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
บรรทัดที่13
ลองแก้ดูนะ
Conn.open "DBQ=" & Server.MapPath ("database1.mdb" )&";Driver={Microsoft Access Driver (*.mdb)}"
บรรทัดที่16
Set RS =Server.CreateObject("ADODB.Recordset")
RS.open Sql,Conn,1,3
|
|
|
|
|
Date :
30 ม.ค. 2551 00:35:52 |
By :
beginner |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|