|
|
|
ไม่สามารถ ลบ เพิ่ม แก้ไข ช่วยเช็คโค้ดหน่อยครับ มันไม่แสดง เออเรอที่จุดไหนเลย |
|
|
|
|
|
|
|
ช่วยเช็คให้หน่อย ครับ หาจุดผิดพลาดไม่ได้เลย
Code (ASP)
<% Option Explicit %>
<html>
<head>
<title></title>
</head>
<body>
<form name="frmMain" method="get" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
<input type="hidden" name="hdnCmd" value="">
<table width="599" border="1">
<tr><th>Keyword
<input name="txtKeyword" type="text" id="txtKeyword" value="<%=Request.QueryString("txtKeyword")%>">
<input type="submit" value="Search"></th>
</tr>
</table>
<%
if Request.QueryString("txtKeyword") <> "" Then
Dim Conn,strSQL,objRec,strKeyword,objExec,i
strKeyword = Request.QueryString("txtKeyword")
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "Driver={SQL Server};Server=.\SQL2008;Database=STOCK2015;UID=sa;PWD=12349789;"
'*** Add Condition ***'
If Request.Form("hdnCmd") = "Add" Then
strSQL = "INSERT INTO CSBARCODE "
strSQL = strSQL & "(BARCODE,PRODUCTCODE,BARCODETEXT,UNITCODE,PRICE,STATUS) "
strSQL = strSQL & "VALUES "
strSQL = strSQL & "('"& Request.Form("txtAddBARCODE") &"','"& Request.Form("txtAddBARCODE_ID") &"', '"& Request.Form("txtAddBARCODE_NAME") &"' "
strSQL = strSQL & ",'"& Request.Form("txtAddUNIT") &"','"& Request.Form("txtAddPRICE") &"', '"& Request.Form("txtAddSTATUS") &"') "
Set objExec = Conn.Execute(strSQL)
End IF
'*** Update Condition ***'
If Request.Form("hdnCmd") = "Update" Then
strSQL = "UPDATE CSBARCODE SET "
strSQL = strSQL & "BARCODE= '"& Request.Form("txtEditBARCODE") &"' "
strSQL = strSQL & ",BARCODETEXT = '"& Request.Form("txtEditBARCODE_NAME") &"' "
strSQL = strSQL & ",UNITCODE ='"& Request.Form("txtEditUNIT") &"' "
strSQL = strSQL & ",PRICE = '"& Request.Form("txtEditPRICE") &"' "
strSQL = strSQL & ",STATUS = '"& Request.Form("txtEditSTATUS") &"' "
strSQL = strSQL & "WHERE (CSBARCODE.PRODUCTCODE = '"& Request.Form("hdnEditID") &"')"
Set objExec = Conn.Execute(strSQL)
End If
'*** Delete Condition ***'
If Request.QueryString("Action") = "Del" Then
strSQL = "DELETE FROM CSBARCODE "
strSQL = strSQL &"WHERE CSBARCODE = '"& Request.QueryString("CusID") &"' "
Set objExec = Conn.Execute(strSQL)
End IF
'*** Search By Name or Email ***'
strSQL = "SELECT CSPRODUCT.CODE AS ID "
strSQL = strSQL & ",CSPRODUCT.NAMETH AS NAME "
strSQL = strSQL & ",CSBARCODE.BARCODETEXT AS BARCODETEXT "
strSQL = strSQL & ",CSBARCODE.PRODUCTCODE AS PRODUCTCODE "
strSQL = strSQL & ",CSPRODUCT.MAINGROUP AS MAINGROUP "
strSQL = strSQL & ",CSPRODUCT.SUBGROUP1 AS SUBGROUP "
strSQL = strSQL & ",CSPRODUCT.SUBGROUP2 AS BRAND "
strSQL = strSQL & ",CSBARCODE.UNITCODE "
strSQL = strSQL & ",CSBARCODE.PRICE "
strSQL = strSQL & ",CSBARCODE.STATUS "
strSQL = strSQL & ",CSBARCODE.BARCODE "
strSQL = strSQL & "FROM CSPRODUCT "
strSQL = strSQL & "LEFT JOIN CSBARCODE ON CSPRODUCT.CODE = CSBARCODE.PRODUCTCODE "
strSQL = strSQL & "WHERE (BARCODE LIKE '%"& Request.QueryString("txtKeyword") &"%')"
strSQL = strSQL & "ORDER BY CSPRODUCT.NAMETH,CSPRODUCT.MAINGROUP,SUBGROUP1,SUBGROUP2 ASC"
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, Conn, 1,3
If objRec.EOF Then
Response.write (" Not found record.")
Else
Dim PageLen,PageNo,TotalRecord,TotalPage,No,intID
PageLen = 10
PageNo = Request.QueryString("Page")
if PageNo = "" Then PageNo = 1
TotalRecord = objRec.RecordCount
objRec.PageSize = PageLen
TotalPage = objRec.PageCount
objRec.AbsolutePage = PageNo
%>
<table width="100%" border="1" align="center">
<tr bgcolor="#FFFF00">
<th width="169"> <div align="center">ID</div></th>
<th width="317"> <div align="center">NAME</div></th>
<th width="297"> <div align="center">BARCODE NAME</div></th>
<th width="215"> <div align="center">BARCODE ID</div></th>
<th width="105"> <div align="center">MAINGROUP</div></th>
<th width="87"> <div align="center">SUBGROUP</div></th>
<th width="109"> BRAND</th>
<th width="42"> <div align="center">UNIT</div></th>
<th width="119"> <div align="center">PRICE</div></th>
<th width="64"> <div align="center">STATUS</div></th>
<th width="83"> <div align="center">BARCODE</div></th>
<th width="31"> <div align="center">Edit</div></th>
<th width="49"> <div align="center">Delete</div></th>
</tr>
<%
NO=1
Do While Not objRec.EOF And NO <= PageLen
IF objRec.Fields("BARCODE").Value = Request.QueryString("CusID") and Request.QueryString("Action") = "Edit" Then
%>
<tr bgcolor="#99CC33">
<td><DIV><input name="txtEditID" type="text" id="txtEditID" value="<%=objRec.Fields("ID").Value%>" size="15">
<input type="hidden" name="hdnEditID" size="5" value="<%=objRec.Fields("ID").Value%>"></DIV></td>
<td><DIV><label for="txtNAME"></label><input name="txtNAME" type="text" id="txtNAME" value="<%=objRec.Fields("NAME").Value%>" size="20"></DIV></td><td><div>
<label for="txtEditBARCODE_NAME"></label><input name="txtEditBARCODE_NAME" type="text" id="txtEditBARCODE_NAME" value="<%=objRec.Fields("BARCODETEXT").Value%>"></div></td>
<td><div><label for="txtEditBARCODE_ID"></label><input name="txtEditBARCODE_ID" type="text" id="txtEditBARCODE_ID" value="<%=objRec.Fields("PRODUCTCODE").Value%>"></div></td>
<td><DIV><label for="txtMAINGROUP"></label><input name="txtMAINGROUP" type="text" id="txtMAINGROUP" value="<%=objRec.Fields("MAINGROUP").Value%>" size="15"></DIV></td><td><div align="center">
<input type="text" name="txtEditSUBGROUP" size="10" value="<%=objRec.Fields("SUBGROUP").Value%>"></div></td>
<td><input type="text" name="txtEditBRAND" size="10" value="<%=objRec.Fields("BRAND").Value%>"></td>
<td><DIV><input type="text" name="txtEditUNIT" size="7" value="<%=objRec.Fields("UNITCODE").Value%>"></DIV></td>
<td><DIV align="center"><input type="text" name="txtEditPRICE" size="7" value="<%=objRec.Fields("PRICE").Value%>"></div></td>
<td><DIV><input type="text" name="txtEditSTATUS" size="7" value="<%=objRec.Fields("STATUS").Value%>"></DIV></td>
<td><DIV><input type="text" name="txtEditBARCODE" size="7" value="<%=objRec.Fields("BARCODE").Value%>"></div></td>
<td colspan="2" align="right"><DIV align="center">
<input name="btnAdd" type="button" id="btnUpdate" value="Update" OnClick="frmMain.hdnCmd.value='Update';frmMain.submit();">
<input name="btnAdd" type="button" id="btnCancel" value="Cancel" OnClick="window.location='<%=Request.ServerVariables("SCRIPT_NAME")%>?&Page=<%=PageNo%>&txtKeyword=<%=strKeyword%>';">
</div></td>
</tr>
<%
'********* ELSE ********'
Else
%>
<tr bgcolor="#66FFCC"><td><DIV> <%=objRec.Fields("ID").Value%> </DIV></td>
<td><DIV> <%=objRec.Fields("NAME").Value%></DIV></td>
<td><DIV> <%=objRec.Fields("BARCODETEXT").Value%><br></DIV></td>
<td><DIV> <%=objRec.Fields("PRODUCTCODE").Value%></DIV></td>
<td><DIV> <%=objRec.Fields("MAINGROUP").Value%></DIV></td>
<td><DIV> <%=objRec.Fields("SUBGROUP").Value%></DIV></td>
<td><DIV> <%=objRec.Fields("BRAND").Value%></DIV></td>
<td><DIV> <%=objRec.Fields("UNITCODE").Value%></DIV></td>
<td><DIV> <%=objRec.Fields("PRICE").Value%></DIV></td>
<td><DIV> <%=objRec.Fields("STATUS").Value%></DIV></td>
<td><DIV> <%=objRec.Fields("BARCODE").Value%></DIV></td>
<td align="center"><a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?Action=Edit&Page=<%=PageNo%>&txtKeyword=<%=strKeyword%>&CusID=<%=objRec.Fields("BARCODE").Value%>">Edit</a></td>
<td align="center"><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='<%=Request.ServerVariables("SCRIPT_NAME")%>?&txtKeyword=<%=strKeyword%>&Page=<%=PageNo%>&Action=Del&CusID=<%=objRec.Fields("BARCODE").Value%>';}">Delete</a></td>
</tr>
<%
End IF
'********* END IF ****'
NO = NO + 1
objRec.MoveNext
Loop
%>
<tr bgcolor="#66FF66">
<td> </td>
<td> </td>
<td><div>
<label for="txtAddBARCODE_NAME"></label>
<input name="txtAddBARCODE_NAME" type="text" id="txtAddBARCODE_NAME" size="20">
</div></td>
.<td><div>
<label for="txtAddBARCODE_ID"></label>
<input name="txtAddBARCODE_ID" type="text" id="txtAddBARCODE_ID" size="20">
</div></td>
<td> </td>
<td> </td>
<td> </td>
<td><DIV><input type="text" name="txtAddUNIT" size="7" id="txtAddUNIT"></div></td>
<td><div align="center"><input type="text" name="txtAddPRICE" size="7"></div></td>
<td><DIV><input type="text" name="txtAddSTATUS" size="7"></DIV></td>
<td><DIV><input type="text" name="txtAddBARCODE" size="7" id="txtAddBARCODE"></DIV></td>
<td colspan="2" align="right"><div align="center">
<input name="btnAdd" type="button" id="btnAdd" value="Add" OnClick="frmMain.hdnCmd.value='Add';frmMain.submit();">
</div></td>
</tr>
</table>
Total : <%=TotalRecord%> Page <%=PageNo%> All Page <%=TotalPage%>
<% IF Cint(PageNo) > 1 then %>
<a href="<%Request.ServerVariables("SCRIPT_NAME")%>?txtKeyword=<%=strKeyword%>&Page=1"><< First</a>
<a href="<%Request.ServerVariables("SCRIPT_NAME")%>?txtKeyword=<%=strKeyword%>&Page=<%=PageNo-1%>">< Back</a>
<% End IF%>
<% IF Cint(PageNo) < TotalPage Then %>
<a href="<%Request.ServerVariables("SCRIPT_NAME")%>?txtKeyword=<%=strKeyword%>&Page=<%=PageNo+1%>">Next ></a>
<a href="<%Request.ServerVariables("SCRIPT_NAME")%>?txtKeyword=<%=strKeyword%>&Page=<%=TotalPage%>">Last >></a>
<% End IF%>
<br>
Go to
<% For intID = 1 To TotalPage%>
<% if intID = Cint(PageNo) Then%>
<b><%=intID%></b>
<%Else%>
<a href="<%Request.ServerVariables("SCRIPT_NAME")%>?txtKeyword=<%=strKeyword%>&Page=<%=intID%>"><%=intID%></a>
<%End IF%>
<%Next%>
<%
objRec.Close()
Conn.Close()
Set objRec = Nothing
Set Conn = Nothing
End IF
End IF
%>
</form>
</body>
</html>
Tag : ASP
|
|
|
|
|
|
Date :
2014-10-09 15:11:52 |
By :
dendeenarat |
View :
1588 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (ASP)
strSQL = "UPDATE CSBARCODE SET "
strSQL = strSQL & "BARCODE= '"& Request.Form("txtEditBARCODE") &"' "
strSQL = strSQL & ",BARCODETEXT = '"& Request.Form("txtEditBARCODE_NAME") &"' "
strSQL = strSQL & ",UNITCODE ='"& Request.Form("txtEditUNIT") &"' "
strSQL = strSQL & ",PRICE = '"& Request.Form("txtEditPRICE") &"' "
strSQL = strSQL & ",STATUS = '"& Request.Form("txtEditSTATUS") &"' "
strSQL = strSQL & "WHERE (CSBARCODE.PRODUCTCODE = '"& Request.Form("hdnEditID") &"')"
Set objExec = Conn.Execute(strSQL)
Response.write Err.Description
Response.End
มันน่าจะหยุดและแสดง Error ถ้าเงื่อนไขถูกต้องน่ะครับ
|
|
|
|
|
Date :
2014-10-09 15:31:24 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มันไม่แสดงข้อผิดพลาดเลย ครับ ไม่เหมือน php ถ้าเออเรอก็จะเเจ้ง asp ไม่แจ้งข้อความว่าผิดพลาดที่ไหนครับ นี่กดแล้วไม่มีการเปลียนแปลงอะไรเลย -0- T^T ขอบคุณมากนะครับ
|
|
|
|
|
Date :
2014-10-09 16:13:43 |
By :
dendeenarat |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมว่ามันไม่ทำงานครับ คุณลอง Response.write("XXX") แล้วไล่ Step ไปเรื่อย ๆ ครับ
|
|
|
|
|
Date :
2014-10-09 16:20:02 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่ทราบ ว่าต้องทำยังไงบ้าง
ครับ ลองทำตัวอย่างให้ดูหน่อยครับ
|
|
|
|
|
Date :
2014-10-09 16:45:15 |
By :
dendeenarat |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|