|
|
|
เขียน ASP ทำ sql update database access : ขึ้น error "Microsoft VBScript runtime error '800a01a8' " คะ แก้ไขยังงัยดีคะ / ขอบคุณคะ |
|
|
|
|
|
|
|
Code (ASP)
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-874">
<script language="JavaScript">
function ch(){
var frm = document.form1
if (frm.Ecode1.value == "") {
alert("กรุณาคีย์.รหัสผู้นำเสนอ.ด้วยคะ")
frm.Ecode1.focus()
return false
}
if (confirm("ยืนยันการส่งข้อมูลนี้"))
{return true;}
else
{return false;}
}
</script>
<title>Kaizen System</title>
</head>
<body bgcolor="white">
<center>
<table width="98%" height="40"><tr>
<td background="../../images_default/backboard.gif" align="center"><font color="DarkBlue" size=3><b>
Kaizen System </b></font></td>
</tr></table>
<%
Dim SpamProtect 'Protect Repeated Submit
Dim KNo, ECode1
If Session("SpamProtect")=Null Then
Session("SpamProtect")=False
End If
set conn=Server.CreateObject("ADODB.Connection")
str="Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.Mappath("/kaizen/Kaizen.mdb")
Conn.Open str,"",""
RS.Open sql, Conn, 1, 3
KNo = Request.Form("KNo")
Ecode1=request.form("Ecode1")
DateTime=Date()
set RS = conn.execute(sql)
sql="Update Kaizen Set KNo = @KNo, Ecode1 = @ECode1 where KNo = @KNo"
%>
<%
if (Ecode1<>"" ) then
RS.AddNew
RS("KNo")=KNo
RS("Ecode1")=Ecode1
Rs("datetime")=datetime
RS.Update
end if
if not(RS.EOF) Then
RS.MoveFirst
End If
%>
<table width="98%" border="1">
<tr bgcolor="#CCCCCC"><b>
<td align="center">No.</td>
<td align="center" >ECode1</td> </b></tr>
<tr bgcolor=<%=bg%>> <font size="-1">
</td><td align="center"><%=RS("KNo")%></td>
</font>
<td align="center"><font size="-1"><%=RS("ECode1")%></font></td>
</tr>
</table>
</body>
</html>
<FORM action="Kaizen.asp" method="post" onSubmit="return ch()" name="form1">
<p> <table width="90%" height="40"><tr><td background="../../images/230951_4311057.gif" align="center"><font color="#0052A4" size=+2>Register</font> </td></tr></table>
<table width="90%" align="center" bgcolor="#E4E2FE" >
<tr>
<td align="right"><b>วันที่เสนอ : </b> </td>
<td colspan="1"align="left" valign="top"><input size="9" type="text"name="ECode1" >
<b> KNo: </b> <input size="9" type="text"name="KNo" >
</td>
</tr>
<tr>
<td height="26" colspan=11 align="middle" valign="top" bgcolor="#FFD5E1"><br>
<input type="submit" value="ส่งข้อมูล" >
<input type="reset" value="Clear" >
<!-- <p><a href="Read_meeting1.asp" target="_blank">ดูข้อมูลทั้งหมด</a> --> </td>
</tr>
</table>
</FORM>
Tag : ASP, Ms Access, HTML/CSS, JavaScript, VBScript, Web (ASP.NET)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Quote: set conn=Server.CreateObject("ADODB.Connection")
str="Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.Mappath("/kaizen/Kaizen.mdb")
Conn.Open str,"",""
RS.Open sql, Conn, 1, 3
KNo = Request.Form("KNo")
Ecode1=request.form("Ecode1")
DateTime=Date()
set RS = conn.execute(sql)
sql="Update Kaizen Set KNo = @KNo, Ecode1 = @ECode1 where KNo = @KNo"
ตรงนี้น่าจะผิดครับ คุณ RS.Open sql, Conn, 1, 3 ทั้ง ๆ ที่ตัวแปร sql ไม่มี ปกติผมใช้แบบนี้ครับ
Code (ASP)
<%
Dim Conn,strSQL,objExec
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("mydatabase.mdb"),"" , ""
strSQL = "UPDATE customer SET "
strSQL = strSQL&"CustomerID = '"&Request.Form("txtCustomerID")&"' "
strSQL = strSQL&",Name = '"&Request.Form("txtName")&"' "
strSQL = strSQL&",Email = '"&Request.Form("txtEmail")&"' "
strSQL = strSQL&",CountryCode = '"&Request.Form("txtCountryCode")&"' "
strSQL = strSQL&",Budget = '"&Request.Form("txtBudget")&"' "
strSQL = strSQL&",Used = '"&Request.Form("txtUsed")&"' "
strSQL = strSQL&"WHERE CustomerID = '"&Request.QueryString("CusID")&"' "
Set objExec = Conn.Execute(strSQL)
If Err.Number = 0 Then
Response.write("Save Done.")
Else
Response.write("Error Save ["&strSQL&"] ("&Err.Description&")")
End IF
Conn.Close()
Set objExec = Nothing
Set Conn = Nothing
%>
Go to : ASP Microsoft Access Edit/Update Record
|
|
|
|
|
Date :
2011-08-29 17:34:04 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|