ASP delete records problem - Inetserver

This is a discussion on ASP delete records problem - Inetserver ; I have an Acces database classical ASP. In this db I have 2 tables. I am not really a ASP programmer but with the help of example-scripts I succeeded in functioning the whole thing. Recently I added a third table ...

+ Reply to Thread
Results 1 to 3 of 3

ASP delete records problem

  1. Default ASP delete records problem

    I have an Acces database classical ASP. In this db I have 2 tables. I am not
    really a ASP programmer but with the help of example-scripts I succeeded in
    functioning the whole thing. Recently I added a third table and now I have
    the problem that I cannot delete records from it. I can delete records from
    table 1 and 2 . For the deleting of records from table 3 I used the script
    of the page for deleting the records from table one and two. I changed it a
    little but it did not functtion. Can someone tell me what is wrong with it.





    Situation:

    Table 1 "Products" with many field, Field Pnr=prim key (autonumber)

    Table 2 "Keyws" with 2 fields, Pnr = prim sleutel (number)

    There is a relation between the tables (ref integrity)



    The new table "Members" is independent from the other tables.The first
    field is Member = prim key. All fields in this table are Text-type





    The "ACTIONPAGE" (for deleting records from table 1 and 2)



    <BODY>

    <%

    Dim strID

    strID=Request.Form("Pnr")



    DIM Conn

    Set Conn=Server.CreateObject("ADODB.connection")

    Conn.Open "DSN=x"



    strSQL = "DELETE FROM Keyws WHERE Pnr=" & CLng(strID)

    Conn.Execute(strSQL)

    strSQL = "DELETE FROM Products WHERE Pnr=" & CLng(strID)

    Conn.Execute(strSQL)



    Conn.Close

    Set Conn = Nothing

    %>

    <H2>The record has been deleted (I hope)</H2>

    </BODY>





    The "CHANGED ACTIONPAGE" (for deleting records from table 3)

    <BODY>

    <%

    Dim strID

    strID=Request.Form("Member")



    DIM Conn

    Set Conn=Server.CreateObject("ADODB.connection")

    Conn.Open "DSN=x"



    strSQL = "DELETE FROM Members WHERE Member=" & CLng(strID)

    Conn.Execute(strSQL)



    Conn.Close

    Set Conn = Nothing

    %>

    <H2>The record has been deleted (I hope)</H2>

    </BODY>



    When I try this page I get the message Datatypes do not match in Criteria
    expressions. The message refers to the line wich starts with strSQL = ....



    I tried other scripts from the internet but did not succeed. Can someone
    tell me what is wrong with mine.



    Thanks in advance,

    Marcel





  2. Default Re: ASP delete records problem

    Basr wrote:
    > strSQL = "DELETE FROM Members WHERE Member=" & CLng(strID)
    >
    > Conn.Execute(strSQL)
    >
    >
    > When I try this page I get the message Datatypes do not match in
    > Criteria expressions. The message refers to the line wich starts with
    > strSQL = ....


    I think you are wrong about this. You would only get this error from the
    attempt to execute the sql statement created in the strSQL=... line.

    Is Member a numeric field? See this post for the rules for delimiting
    criteria values:
    http://www.google.com/groups?hl=en&l...TNGP12.phx.gbl


    This type of problem can be avoided by using parameters instead of dynamic
    sql, either via saved parameter queries per the above post, or via a Command
    object as described in this post:
    http://groups-beta.google.com/group/...e36562fee7804e

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"



  3. Default Re: ASP delete records problem

    Thanks Bob
    I found the solution, it works fine now.
    Marcel


    "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> schreef in bericht
    news:%23DkxV0FPGHA.2012@TK2MSFTNGP14.phx.gbl...
    > Basr wrote:
    > > strSQL = "DELETE FROM Members WHERE Member=" & CLng(strID)
    > >
    > > Conn.Execute(strSQL)
    > >
    > >
    > > When I try this page I get the message Datatypes do not match in
    > > Criteria expressions. The message refers to the line wich starts with
    > > strSQL = ....

    >
    > I think you are wrong about this. You would only get this error from the
    > attempt to execute the sql statement created in the strSQL=... line.
    >
    > Is Member a numeric field? See this post for the rules for delimiting
    > criteria values:
    >

    http://www.google.com/groups?hl=en&l...TNGP12.phx.gbl
    >
    >
    > This type of problem can be avoided by using parameters instead of dynamic
    > sql, either via saved parameter queries per the above post, or via a

    Command
    > object as described in this post:
    >

    http://groups-beta.google.com/group/...e36562fee7804e
    >
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >




+ Reply to Thread

Similar Threads

  1. Automatically Delete Records from a Table
    By Application Development in forum ADO DAO RDO RDS
    Replies: 2
    Last Post: 11-01-2007, 07:11 PM
  2. Delete midrange of records with DBU
    By Application Development in forum Clipper
    Replies: 10
    Last Post: 07-31-2006, 04:49 AM
  3. delete records from database
    By Application Development in forum Inetserver
    Replies: 8
    Last Post: 05-16-2006, 10:14 PM
  4. delete related records
    By Application Development in forum Inetserver
    Replies: 3
    Last Post: 11-21-2005, 07:53 PM
  5. need a utility to delete records ( dos )
    By Application Development in forum Clarion
    Replies: 0
    Last Post: 09-21-2005, 10:14 PM