Jump to content

salim

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by salim

  1. salim

    delete

    well, I am sorry to ask this, but here is my stuff if you could tell me how things can be.the message I get it is:ADODB.Field error '800a0bcd' Unknown runtime error /salem/TMP8hhsk6kgqg.asp, line 117 but I beleive after trying and trying to sort this, I never get what I want at the end, that's why I start another page from scratch in case I messed with the codes, now I can't see really well...deleteproducts.asp is the page where I submit the productid and it will be deleted from my database which contains a table called products and the PK is ProductID.<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%><!--#include file="Connections/connection1.asp" --><%' *** Edit Operations: declare variablesDim MM_editActionDim MM_abortEditDim MM_editQueryDim MM_editCmdDim MM_editConnectionDim MM_editTableDim MM_editRedirectUrlDim MM_editColumnDim MM_recordIdDim MM_fieldsStrDim MM_columnsStrDim MM_fieldsDim MM_columnsDim MM_typeArrayDim MM_formValDim MM_delimDim MM_altValDim MM_emptyValDim MM_iMM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))If (Request.QueryString <> "") ThenMM_editAction = MM_editAction & "?" & Request.QueryStringEnd If' boolean to abort record editMM_abortEdit = false' query string to executeMM_editQuery = ""%><%' *** Delete Record: declare variablesif (CStr(Request("MM_delete")) = "form1" And CStr(Request("MM_recordId")) <> "") ThenMM_editConnection = MM_connection1_STRINGMM_editTable = "Products"MM_editColumn = "ProductID"MM_recordId = "" + Request.Form("MM_recordId") + ""MM_editRedirectUrl = "delproducts.asp"' append the query string to the redirect URLIf (MM_editRedirectUrl <> "" And Request.QueryString <> "") ThenIf (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") ThenMM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryStringElseMM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryStringEnd IfEnd IfEnd If%><%' *** Delete Record: construct a sql delete statement and execute itIf (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then' create the sql delete statementMM_editQuery = "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordIdIf (Not MM_abortEdit) Then' execute the deleteSet MM_editCmd = Server.CreateObject("ADODB.Command")MM_editCmd.ActiveConnection = MM_editConnectionMM_editCmd.CommandText = MM_editQueryMM_editCmd.ExecuteMM_editCmd.ActiveConnection.CloseIf (MM_editRedirectUrl <> "") ThenResponse.Redirect(MM_editRedirectUrl)End IfEnd IfEnd If%><%Dim deleteproduct__MMColParamdeleteproduct__MMColParam = "1"If (Request.Form("ProductID") <> "") Then deleteproduct__MMColParam = Request.Form("ProductID")End If%><%Dim deleteproductDim deleteproduct_numRowsSet deleteproduct = Server.CreateObject("ADODB.Recordset")deleteproduct.ActiveConnection = MM_connection1_STRINGdeleteproduct.Source = "SELECT ProductID FROM Products WHERE ProductID = " + Replace(deleteproduct__MMColParam, "'", "''") + ""deleteproduct.CursorType = 0deleteproduct.CursorLocation = 2deleteproduct.LockType = 1deleteproduct.Open()deleteproduct_numRows = 0%><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><form name="form1" method="POST" action="<%=MM_editAction%>"><input type="text" name="textfield"><input type="submit" name="Submit" value="Submit"><input type="hidden" name="MM_delete" value="form1"><input type="hidden" name="MM_recordId" value="<%= deleteproduct.Fields.Item("ProductID").Value %>"></form></body></html><%deleteproduct.Close()Set deleteproduct = Nothing%>product.asp page ( from where products will be shown )<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!--#include file="../../Connections/addproduct.asp" --><%Dim RecordsetproductsDim Recordsetproducts_numRowsSet Recordsetproducts = Server.CreateObject("ADODB.Recordset")Recordsetproducts.ActiveConnection = MM_addproduct_STRINGRecordsetproducts.Source = "SELECT * FROM Products"Recordsetproducts.CursorType = 0Recordsetproducts.CursorLocation = 2Recordsetproducts.LockType = 1Recordsetproducts.Open()Recordsetproducts_numRows = 0%><%Dim Repeat1__numRowsDim Repeat1__indexRepeat1__numRows = 2Repeat1__index = 0Recordsetproducts_numRows = Recordsetproducts_numRows + Repeat1__numRows%><%' *** Recordset Stats, Move To Record, and Go To Record: declare stats variablesDim Recordsetproducts_totalDim Recordsetproducts_firstDim Recordsetproducts_last' set the record countRecordsetproducts_total = Recordsetproducts.RecordCount' set the number of rows displayed on this pageIf (Recordsetproducts_numRows < 0) ThenRecordsetproducts_numRows = Recordsetproducts_totalElseif (Recordsetproducts_numRows = 0) ThenRecordsetproducts_numRows = 1End If' set the first and last displayed recordRecordsetproducts_first = 1Recordsetproducts_last = Recordsetproducts_first + Recordsetproducts_numRows - 1' if we have the correct record count, check the other statsIf (Recordsetproducts_total <> -1) ThenIf (Recordsetproducts_first > Recordsetproducts_total) ThenRecordsetproducts_first = Recordsetproducts_totalEnd IfIf (Recordsetproducts_last > Recordsetproducts_total) ThenRecordsetproducts_last = Recordsetproducts_totalEnd IfIf (Recordsetproducts_numRows > Recordsetproducts_total) ThenRecordsetproducts_numRows = Recordsetproducts_totalEnd IfEnd If%><%Dim MM_paramName %><%' *** Move To Record and Go To Record: declare variablesDim MM_rsDim MM_rsCountDim MM_sizeDim MM_uniqueColDim MM_offsetDim MM_atTotalDim MM_paramIsDefinedDim MM_paramDim MM_indexSet MM_rs = RecordsetproductsMM_rsCount = Recordsetproducts_totalMM_size = Recordsetproducts_numRowsMM_uniqueCol = ""MM_paramName = ""MM_offset = 0MM_atTotal = falseMM_paramIsDefined = falseIf (MM_paramName <> "") ThenMM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")End If%><%' *** Move To Record: handle 'index' or 'offset' parameterif (Not MM_paramIsDefined And MM_rsCount <> 0) then' use index parameter if defined, otherwise use offset parameterMM_param = Request.QueryString("index")If (MM_param = "") ThenMM_param = Request.QueryString("offset")End IfIf (MM_param <> "") ThenMM_offset = Int(MM_param)End If' if we have a record count, check if we are past the end of the recordsetIf (MM_rsCount <> -1) ThenIf (MM_offset >= MM_rsCount Or MM_offset = -1) Then ' past end or move lastIf ((MM_rsCount Mod MM_size) > 0) Then ' last page not a full repeat regionMM_offset = MM_rsCount - (MM_rsCount Mod MM_size)ElseMM_offset = MM_rsCount - MM_sizeEnd IfEnd IfEnd If' move the cursor to the selected recordMM_index = 0While ((Not MM_rs.EOF) And (MM_index < MM_offset Or MM_offset = -1))MM_rs.MoveNextMM_index = MM_index + 1WendIf (MM_rs.EOF) Then MM_offset = MM_index ' set MM_offset to the last possible recordEnd IfEnd If%><%' *** Move To Record: if we dont know the record count, check the display rangeIf (MM_rsCount = -1) Then' walk to the end of the display range for this pageMM_index = MM_offsetWhile (Not MM_rs.EOF And (MM_size < 0 Or MM_index < MM_offset + MM_size))MM_rs.MoveNextMM_index = MM_index + 1Wend' if we walked off the end of the recordset, set MM_rsCount and MM_sizeIf (MM_rs.EOF) ThenMM_rsCount = MM_indexIf (MM_size < 0 Or MM_size > MM_rsCount) ThenMM_size = MM_rsCountEnd IfEnd If' if we walked off the end, set the offset based on page sizeIf (MM_rs.EOF And Not MM_paramIsDefined) ThenIf (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) ThenIf ((MM_rsCount Mod MM_size) > 0) ThenMM_offset = MM_rsCount - (MM_rsCount Mod MM_size)ElseMM_offset = MM_rsCount - MM_sizeEnd IfEnd IfEnd If' reset the cursor to the beginningIf (MM_rs.CursorType > 0) ThenMM_rs.MoveFirstElseMM_rs.RequeryEnd If' move the cursor to the selected recordMM_index = 0While (Not MM_rs.EOF And MM_index < MM_offset)MM_rs.MoveNextMM_index = MM_index + 1WendEnd If%><%' *** Move To Record: update recordset stats' set the first and last displayed recordRecordsetproducts_first = MM_offset + 1Recordsetproducts_last = MM_offset + MM_sizeIf (MM_rsCount <> -1) ThenIf (Recordsetproducts_first > MM_rsCount) ThenRecordsetproducts_first = MM_rsCountEnd IfIf (Recordsetproducts_last > MM_rsCount) ThenRecordsetproducts_last = MM_rsCountEnd IfEnd If' set the boolean used by hide region to check if we are on the last recordMM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)%><%' *** Go To Record and Move To Record: create strings for maintaining URL and Form parametersDim MM_keepNoneDim MM_keepURLDim MM_keepFormDim MM_keepBothDim MM_removeListDim MM_itemDim MM_nextItem' create the list of parameters which should not be maintainedMM_removeList = "&index="If (MM_paramName <> "") ThenMM_removeList = MM_removeList & "&" & MM_paramName & "="End IfMM_keepURL=""MM_keepForm=""MM_keepBoth=""MM_keepNone=""' add the URL parameters to the MM_keepURL stringFor Each MM_item In Request.QueryStringMM_nextItem = "&" & MM_item & "="If (InStr(1,MM_removeList,MM_nextItem,1) = 0) ThenMM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item))End IfNext' add the Form variables to the MM_keepForm stringFor Each MM_item In Request.FormMM_nextItem = "&" & MM_item & "="If (InStr(1,MM_removeList,MM_nextItem,1) = 0) ThenMM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item))End IfNext' create the Form + URL string and remove the intial '&' from each of the stringsMM_keepBoth = MM_keepURL & MM_keepFormIf (MM_keepBoth <> "") Then MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)End IfIf (MM_keepURL <> "") ThenMM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)End IfIf (MM_keepForm <> "") ThenMM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)End If' a utility function used for adding additional parameters to these stringsFunction MM_joinChar(firstItem)If (firstItem <> "") ThenMM_joinChar = "&"ElseMM_joinChar = ""End IfEnd Function%><%' *** Move To Record: set the strings for the first, last, next, and previous linksDim MM_keepMoveDim MM_moveParamDim MM_moveFirstDim MM_moveLastDim MM_moveNextDim MM_movePrevDim MM_urlStrDim MM_paramListDim MM_paramIndexDim MM_nextParamMM_keepMove = MM_keepBothMM_moveParam = "index"' if the page has a repeated region, remove 'offset' from the maintained parametersIf (MM_size > 1) ThenMM_moveParam = "offset"If (MM_keepMove <> "") ThenMM_paramList = Split(MM_keepMove, "&")MM_keepMove = ""For MM_paramIndex = 0 To UBound(MM_paramList)MM_nextParam = Left(MM_paramList(MM_paramIndex), InStr(MM_paramList(MM_paramIndex),"=") - 1)If (StrComp(MM_nextParam,MM_moveParam,1) <> 0) ThenMM_keepMove = MM_keepMove & "&" & MM_paramList(MM_paramIndex)End IfNextIf (MM_keepMove <> "") ThenMM_keepMove = Right(MM_keepMove, Len(MM_keepMove) - 1)End IfEnd IfEnd If' set the strings for the move to linksIf (MM_keepMove <> "") Then MM_keepMove = MM_keepMove & "&"End IfMM_urlStr = Request.ServerVariables("URL") & "?" & MM_keepMove & MM_moveParam & "="MM_moveFirst = MM_urlStr & "0"MM_moveLast = MM_urlStr & "-1"MM_moveNext = MM_urlStr & CStr(MM_offset + MM_size)If (MM_offset - MM_size < 0) ThenMM_movePrev = MM_urlStr & "0"ElseMM_movePrev = MM_urlStr & CStr(MM_offset - MM_size)End If%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><script language="JavaScript" type="text/JavaScript"><!--function MM_reloadPage(init) { //reloads the window if Nav4 resizedif (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();}MM_reloadPage(true);//--></script></head><body><div id="Layer6" style="position:absolute; left:7px; top:15px; width:756px; height:117px; z-index:6"> <table width="100%" border="1" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><tr> <td width="28%" height="102"><p align="center"><strong><font color="#009900" size="6">Top Value Supermarket</font></strong></p></td><td width="3%" bgcolor="#009900"><div align="center"></div></td><td width="3%" bgcolor="#00CC00"><div align="center"></div></td><td width="7%" bgcolor="#00FF00"><div align="center"></div></td><td width="59%" bgcolor="#00FF99"><p align="center"><strong><font color="#FF0000" size="5" face="Blackadder ITC">Value always...in your hands</font></strong></p><p align="center"><strong><a href="addproduct.asp">| Home </a>| <a href="../../delproduct.asp">Online Shopping </a>| Site Map | Contact US | My Account | </strong></p></td></tr></table></div><div id="Layer1" style="position:absolute; left:16px; top:437px; width:759px; height:33px; z-index:7"> <table width="98%" border="1" bordercolor="#FFFFFF"><tr bgcolor="#00FF99"> <td bgcolor="#99FF00"> <div align="center"><strong>Contact Us</strong></div></td><td bgcolor="#99FF00"> <div align="center"><strong>Security & Privacy</strong></div></td><td bgcolor="#99FF00"> <div align="center"><strong>Corporate information</strong></div></td><td bgcolor="#99FF00"> <div align="center"><strong>Terms of Service</strong></div></td><td bgcolor="#99FF00"> <div align="center"><strong>Help</strong></div></td></tr></table></div><div id="Layer2" style="position:absolute; left:4px; top:160px; width:760px; height:252px; z-index:8"> <% While ((Repeat1__numRows <> 0) AND (NOT Recordsetproducts.EOF)) %><table width="100%" height="56" border="1" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><tr> <td width="15%" height="25" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><strong>Product Name</strong></td><td width="32%"><%=(Recordsetproducts.Fields.Item("ProductName").Value)%></td><td width="26%" rowspan="2"><p><A HREF="2add_tocart.asp?<%= MM_keepURL & MM_joinChar(MM_keepURL) & "ProductID=" & Recordsetproducts.Fields.Item("ProductID").Value %>"><img name="" src="<%=(Recordsetproducts.Fields.Item("image").Value)%>" alt=""></A></p></td><td width="27%" rowspan="2"><%=(Recordsetproducts.Fields.Item("ProductDescription").Value)%></td></tr><tr> <td height="23" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><strong>Product Price: £</strong></td><td height="23"><%=(Recordsetproducts.Fields.Item("productPrice").Value)%></td></tr></table><hr><% Repeat1__index=Repeat1__index+1Repeat1__numRows=Repeat1__numRows-1Recordsetproducts.MoveNext()Wend%><div id="Layer4" style="position:absolute; width:437px; height:26px; z-index:1; left: 175px; top: 239px;"> <table border="0" width="50%" align="center"><tr> <td width="23%" align="center"> <% If MM_offset <> 0 Then %><a href="<%=MM_moveFirst%>">First</a> <% End If ' end MM_offset <> 0 %> </td><td width="31%" align="center"> <% If MM_offset <> 0 Then %><a href="<%=MM_movePrev%>">Previous</a> <% End If ' end MM_offset <> 0 %> </td><td width="23%" align="center"> <% If Not MM_atTotal Then %><a href="<%=MM_moveNext%>">Next</a> <% End If ' end Not MM_atTotal %> </td><td width="23%" align="center"> <% If Not MM_atTotal Then %><a href="<%=MM_moveLast%>">Last</a> <% End If ' end Not MM_atTotal %> </td></tr></table></div></div><div id="Layer3" style="position:absolute; left:4px; top:136px; width:767px; height:33px; z-index:9"> <table width="100%" border="1" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><tr> <td bgcolor="#99FF33">Food</td><td bgcolor="#99FF33">Non-Food</td><td bgcolor="#99FF33">Cigarrettes</td><td bordercolor="#FFFFFF" bgcolor="#99FF33">Newspaper</td><td bgcolor="#99FF33">Frozen Food</td><td bgcolor="#99FF33">Animal Food</td><td bgcolor="#99FF33">Chocolate&Snacks</td><td bgcolor="#99FF33">Cosmetics&Toiletry</td><td bgcolor="#99FF33">Drink</td></tr></table></div></body></html><%Recordsetproducts.Close()Set Recordsetproducts = Nothing%>
  2. salim

    empty recordset

    I am not quite sure but here is the problem now, it sayss "no records found"look at the red part, maybe it's in there ?<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!--#include file="Connections/connection1.asp" --><%' *** Edit Operations: declare variablesDim MM_editActionDim MM_abortEditDim MM_editQueryDim MM_editCmdDim MM_editConnectionDim MM_editTableDim MM_editRedirectUrlDim MM_editColumnDim MM_recordIdDim MM_fieldsStrDim MM_columnsStrDim MM_fieldsDim MM_columnsDim MM_typeArrayDim MM_formValDim MM_delimDim MM_altValDim MM_emptyValDim MM_iMM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))If (Request.QueryString <> "") Then MM_editAction = MM_editAction & "?" & Request.QueryStringEnd If' boolean to abort record editMM_abortEdit = false' query string to executeMM_editQuery = ""%><%' *** Delete Record: declare variablesif (CStr(Request("MM_delete")) = "form1" And CStr(Request("MM_recordId")) <> "") Then MM_editConnection = MM_connection1_STRING MM_editTable = "Products" MM_editColumn = "ProductID" MM_recordId = "" + Request.Form("MM_recordId") + "" MM_editRedirectUrl = "delproduct.asp" ' append the query string to the redirect URL If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString Else MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString End If End If End If%><%' *** Delete Record: construct a sql delete statement and execute itIf (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then ' create the sql delete statement MM_editQuery = "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordId If (Not MM_abortEdit) Then ' execute the delete Set MM_editCmd = Server.CreateObject("ADODB.Command") MM_editCmd.ActiveConnection = MM_editConnection MM_editCmd.CommandText = MM_editQuery MM_editCmd.Execute MM_editCmd.ActiveConnection.Close If (MM_editRedirectUrl <> "") Then Response.Redirect(MM_editRedirectUrl) End If End IfEnd If%><%Dim Recordsetdel__MMColParamRecordsetdel__MMColParam = "-1"If (Request.Form("ProductID") <> "") Then Recordsetdel__MMColParam = Request.Form("ProductID")End If%><%Dim RecordsetdelDim Recordsetdel_numRowsSet Recordsetdel = Server.CreateObject("ADODB.Recordset")Recordsetdel.ActiveConnection = MM_connection1_STRINGRecordsetdel.Source = "SELECT ProductID FROM Products WHERE ProductID = " + Replace(Recordsetdel__MMColParam, "'", "''") + ""Recordsetdel.CursorType = 0Recordsetdel.CursorLocation = 2Recordsetdel.LockType = 1Recordsetdel.Open()Recordsetdel_numRows = 0%><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><form ACTION="<%=MM_editAction%>" METHOD="POST" name="form1"><% If Not Recordsetdel.EOF Or Not Recordsetdel.BOF Then %><form name="form1" method="POST" action="<%=MM_editAction%>"> <input type="text" name="textfield"> <input type="submit" name="Submit" value="Submit"> <input type="hidden" name="MM_delete" value="form1"> <input type="hidden" name="MM_recordId" value="<%= Recordsetdel.Fields.Item("ProductID").Value %>"></form><% End If ' end Not Recordsetdel.EOF Or NOT Recordsetdel.BOF %><% If Recordsetdel.EOF And Recordsetdel.BOF Then %>No Records Found<% End If ' end Recordsetdel.EOF And Recordsetdel.BOF %></body></html><%Recordsetdel.Close()Set Recordsetdel = Nothing%>
  3. salim

    delete

    I mean to delete a dynamic value
  4. salim

    delete

    I am trying to delete a specific colum, say ProductID = 30 from table Product_tblnow when I use server behaviour to delete, by filtering the recordset it doesn't really delete that particular ID but it goes only the next one in the row, for example:I enter 30the productID deleted is 29, or 28 or which ever productID it encounter.is there anyway to solve this please.by using filter, I use both URL and Form variable but none works, can sql solve this?please let me know
  5. salim

    delete

    I am trying to delete a specific colum, say ProductID = 30 from table Product_tblnow when I use server behaviour to delete, by filtering the recordset it doesn't really delete that particular ID but it goes only the next one in the row, for example:I enter 30the productID deleted is 29, or 28 or which ever productID it encounter.is there anyway to solve this please.by using filter, I use both URL and Form variable but none works, can sql solve this?please let me know
  6. salim

    empty recordset

    well I started another page from scratch, I was told it might be for the template or some html tags, now I am having this problem, and I don't know why, but the recordset isn't empty when I test it it return a value !sorry I don't know how to wrap my codeADODB.Field error '800a0bcd' Unknown runtime error /salem/TMPm0jbk691lx.asp, line 117 the code is as follow<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%><!--#include file="Connections/connection1.asp" --><%' *** Edit Operations: declare variablesDim MM_editActionDim MM_abortEditDim MM_editQueryDim MM_editCmdDim MM_editConnectionDim MM_editTableDim MM_editRedirectUrlDim MM_editColumnDim MM_recordIdDim MM_fieldsStrDim MM_columnsStrDim MM_fieldsDim MM_columnsDim MM_typeArrayDim MM_formValDim MM_delimDim MM_altValDim MM_emptyValDim MM_iMM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))If (Request.QueryString <> "") Then MM_editAction = MM_editAction & "?" & Request.QueryStringEnd If' boolean to abort record editMM_abortEdit = false' query string to executeMM_editQuery = ""%><%' *** Delete Record: declare variablesif (CStr(Request("MM_delete")) = "form1" And CStr(Request("MM_recordId")) <> "") Then MM_editConnection = MM_connection1_STRING MM_editTable = "Products" MM_editColumn = "ProductID" MM_recordId = "" + Request.Form("MM_recordId") + "" MM_editRedirectUrl = "Untitled-2.asp" ' append the query string to the redirect URL If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString Else MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString End If End If End If%><%' *** Delete Record: construct a sql delete statement and execute itIf (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then ' create the sql delete statement MM_editQuery = "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordId If (Not MM_abortEdit) Then ' execute the delete Set MM_editCmd = Server.CreateObject("ADODB.Command") MM_editCmd.ActiveConnection = MM_editConnection MM_editCmd.CommandText = MM_editQuery MM_editCmd.Execute MM_editCmd.ActiveConnection.Close If (MM_editRedirectUrl <> "") Then Response.Redirect(MM_editRedirectUrl) End If End IfEnd If%><%Dim Recordsetdel__MMColParamRecordsetdel__MMColParam = "1"If (Request.Form("ProductID") <> "") Then Recordsetdel__MMColParam = Request.Form("ProductID")End If%><%Dim RecordsetdelDim Recordsetdel_numRowsSet Recordsetdel = Server.CreateObject("ADODB.Recordset")Recordsetdel.ActiveConnection = MM_connection1_STRINGRecordsetdel.Source = "SELECT ProductID FROM Products WHERE ProductID = " + Replace(Recordsetdel__MMColParam, "'", "''") + ""Recordsetdel.CursorType = 0Recordsetdel.CursorLocation = 2Recordsetdel.LockType = 1Recordsetdel.Open()Recordsetdel_numRows = 0%><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><form name="form1" method="POST" action="<%=MM_editAction%>"> <input type="text" name="textfield"> <input type="submit" name="Submit" value="Submit"> <input type="hidden" name="MM_delete" value="form1"> <input type="hidden" name="MM_recordId" value="<%= Recordsetdel.Fields.Item("ProductID").Value %>"></form></body></html><%Recordsetdel.Close()Set Recordsetdel = Nothing%>
  7. salim

    stock control

    QUOTE]Message Forwarded From salim
  8. salim

    t-error message

    am trying to delete a record but I have iniatially thismessage:Microsoft OLE DB Provider for ODBC Drivers error '80040e14' [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'ProductID = , 1567'. /salem/pages/fresh_food/TMP3rfr35u5pa.ASP, line 74 I looked at the meaning but so far I can't see that there is no reserved words I used or space, any idea?that was my first message, after consulting with many in forums, here what I aam gettingthen with some changes I had this message:Microsoft OLE DB Provider for ODBC Drivers error '80040e14' [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'ProductID = <font face='. /salem/TMP4fbu36742n.asp, line 74 okay, this isn't simple as that, it's not about numeric...here is my code, I have made some changes (from instructions from other people in the forum)and may be you could spot where the error is just to get it delete.i did highlight where the changes where madeDELPRODUCT.asp PAGE<%@LANGUAGE="VBSCRIPT"%>MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))If (Request.QueryString <> "") ThenMM_editAction = MM_editAction & "?" & Request.QueryStringEnd If' boolean to abort record editMM_abortEdit = false' query string to executeMM_editQuery = ""%><%' *** Delete Record: declare variablesif (CStr(Request("MM_delete")) = "form1" And CStr(Request("MM_recordId")) <> "") ThenMM_editConnection = MM_connection1_STRINGMM_editTable = "Products"MM_editColumn = "ProductID"MM_recordId = "" + Request.Form("MM_recordId") + ""MM_editRedirectUrl = "delproduct.asp"' append the query string to the redirect URLIf (MM_editRedirectUrl <> "" And Request.QueryString <> "") ThenIf (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") ThenMM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryStringElseMM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryStringEnd IfEnd IfEnd If%><%' *** Delete Record: construct a sql delete statement and execute itIf (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then' create the sql delete statementMM_editQuery = "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordIdIf (Not MM_abortEdit) Then' execute the deleteSet MM_editCmd = Server.CreateObject("ADODB.Command")MM_editCmd.ActiveConnection = MM_editConnectionMM_editCmd.CommandText = MM_editQueryMM_editCmd.ExecuteMM_editCmd.ActiveConnection.CloseIf (MM_editRedirectUrl <> "") ThenResponse.Redirect(MM_editRedirectUrl)End IfEnd IfEnd If%><%Dim delpro__MMColParamdelpro__MMColParam = "1"If (Request.Form("ProductID") <> "") Then delpro__MMColParam = Request.Form("ProductID")End If%><%Dim delproDim delpro_numRowsSet delpro = Server.CreateObject("ADODB.Recordset")delpro.ActiveConnection = MM_connection1_STRINGdelpro.Source = "SELECT ProductID FROM Products WHERE ProductID = " + Replace(delpro__MMColParam, "'", "''") + ""delpro.CursorType = 0delpro.CursorLocation = 2delpro.LockType = 1delpro.Open()delpro_numRows = 0%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Untitled Document</title>function MM_reloadPage(init) { //reloads the window if Nav4 resizedif (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();}MM_reloadPage(true);//--></script></head><body><<%=MM_editAction%>"><table width="75%" border="1" cellpadding="2"><tr> <td>product id</td><td> <input type="text" name="textfield"></td></tr><tr> <td>*</td><td> <input type="submit" name="Submit" value="del"> </td></tr></table><input type="hidden" name="MM_delete" value="form1"><input type="hidden" name="MM_recordId" value="<%= delpro.Fields.Item("ProductID").Value %>"></form></div><div id="Layer6" style="position:absolute; left:7px; top:15px; width:756px; height:117px; z-index:6"> <table width="100%" border="1" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><tr> <td width="28%" height="102"><p align="center"><strong><font color="#009900" size="6">Top Value Supermarket</font></strong></p></td><td width="3%" bgcolor="#009900"><div align="center"></div></td><td width="3%" bgcolor="#00CC00"><div align="center"></div></td><td width="7%" bgcolor="#00FF00"><div align="center"></div></td><td width="59%" bgcolor="#00FF99"><p align="center"><strong><font color="#FF0000" size="5" face="Blackadder ITC">Value always...in your hands</font></strong></p><p align="center"><strong>| Home | Online Shopping | Site Map | Contact US | My Account | </strong></p></td></tr></table></div></body></html><%delpro.Close()Set delpro = Nothing%>this is another example from another pagedeleteproducts.ASP page<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!--#include file="../../Connections/connection1.asp" --><%' *** Edit Operations: declare variablesDim MM_editActionDim MM_abortEditDim MM_editQueryDim MM_editCmdDim MM_editConnectionDim MM_editTableDim MM_editRedirectUrlDim MM_editColumnDim MM_recordIdDim MM_fieldsStrDim MM_columnsStrDim MM_fieldsDim MM_columnsDim MM_typeArrayDim MM_formValDim MM_delimDim MM_altValDim MM_emptyValDim MM_iMM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))If (Request.QueryString <> "") ThenMM_editAction = MM_editAction & "?" & Request.QueryStringEnd If' boolean to abort record editMM_abortEdit = false' query string to executeMM_editQuery = ""%><%' *** Delete Record: declare variablesif (CStr(Request("MM_delete")) = "DELETEPRODUCT" And CStr(Request("MM_recordId")) <> "") ThenMM_editConnection = MM_connection1_STRINGMM_editTable = "Products"MM_editColumn = "ProductID"MM_recordId = "" + Request.Form("MM_recordId") + ""MM_editRedirectUrl = "DELETEPRODUCT.ASP"' append the query string to the redirect URLIf (MM_editRedirectUrl <> "" And Request.QueryString <> "") ThenIf (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") ThenMM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryStringElseMM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryStringEnd IfEnd IfEnd If%><%' *** Delete Record: construct a sql delete statement and execute itIf (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId")) <> "") Then' create the sql delete statementMM_editQuery = "delete from " & MM_editTable & " where " & MM_editColumn & " = " & MM_recordIdIf (Not MM_abortEdit) Then' execute the deleteSet MM_editCmd = Server.CreateObject("ADODB.Command")MM_editCmd.ActiveConnection = MM_editConnectionMM_editCmd.CommandText = MM_editQueryResponse.Write "SQL= " & MM_editQueryResponse.End()MM_editCmd.ExecuteMM_editCmd.ActiveConnection.CloseIf (MM_editRedirectUrl <> "") ThenResponse.Redirect(MM_editRedirectUrl)End IfEnd IfEnd If%><%Dim RecordsetdeleteDim Recordsetdelete_numRowsSet Recordsetdelete = Server.CreateObject("ADODB.Recordset")Recordsetdelete.ActiveConnection = MM_connection1_STRINGRecordsetdelete.Source = "SELECT ProductID FROM Products"Recordsetdelete.CursorType = 0Recordsetdelete.CursorLocation = 2Recordsetdelete.LockType = 1Recordsetdelete.Open()Recordsetdelete_numRows = 0%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><script language="JavaScript" type="text/JavaScript"><!--function MM_reloadPage(init) { //reloads the window if Nav4 resizedif (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();}MM_reloadPage(true);//--></script></head><td width="49%"> <input name="ProductID" type="text" id="ProductID"></td></tr></table><p align="center"> <input type="submit" name="Submit" value="DELETE PRODUCT"></p><input type="hidden" name="MM_recordId"><input type="hidden" name="MM_delete" value="DELETEPRODUCT"><input type="hidden" name="MM_recordId" value="<%= Replace (Recordsetdelete.Fields.Item("ProductID").Value , ",", "")%>"></form></div></body></html><%Recordsetdelete.Close()Set Recordsetdelete = Nothing%>NOTE I DID GET RID OF SOME TAGS JUST TO GET SPACE TO BE ABBLE TO SEND THIS MESSAGE
×
×
  • Create New...