ASP delete records problem

ASP delete records problem

am 28.02.2006 11:51:24 von Basr

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)





<%

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

%>

The record has been deleted (I hope)









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



<%

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

%>

The record has been deleted (I hope)







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

Re: ASP delete records problem

am 28.02.2006 12:49:50 von reb01501

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&lr=&ie=UTF-8&oe=UTF-8&sel m=e6lLVvOcDHA.1204%40TK2MSFTNGP12.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/microsoft.public.inetser ver.asp.db/msg/72e36562fee7804e

--
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"

Re: ASP delete records problem

am 28.02.2006 15:50:23 von Basr

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


"Bob Barrows [MVP]" 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&lr=&ie=UTF-8&oe=UTF-8&sel m=e6lLVvOcDHA.1204%40TK2MSFTNGP12.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/microsoft.public.inetser ver.asp.db/msg/72e36562fee7804e
>
> --
> 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"
>
>