strsql = "SELECT questiontableid FROM questiontable where headtableid ='"& vart1 "&'; DELETE from headtable where headtableid ='"& vart1 &"'; DELETE from questiontable where headtableid ='"& vart1 &"'; DELETE from responsetable where questiontableid ='"& vart2 &"';"
------------------
Doesn't 'expecting the unexpected' make the unexpected expected? webeye.nu
Så enkelt det kan vara ibland:)
Men hur gör jag då när selectens värde ska in i variabeln "vart2"?
strsql = "SELECT questiontableid FROM questiontable where headtableid ='"& vart1 "&'; DELETE from headtable where headtableid ='"& vart1 &"'; DELETE from questiontable where headtableid ='"& vart1 &"'; DELETE from responsetable where questiontableid ='"& vart2 &"';"
strsql = "SELECT questiontableid FROM questiontable where headtableid ='"& vart1 "&'; DELETE from headtable where headtableid ='"& vart1 &"'; DELETE from responsetable where questiontableid IN(SELECT questiontableid FROM questiontable where headtableid ='"& vart1 "&'); DELETE from questiontable where headtableid ='"& vart1 &"'; "
Jag bytte plats på dina två sista DELETE-satser, eftersom det hade blivit lite krångligt annars.
Redigering: Behöver du verkligen din första SELECT-fråga där förresten? Ska du använda ID:t till något annat än till DELETE-satsen?
Mvh,
------------------
All your base are belong to me.
strsql = "DELETE from headtable where headtableid ='"& vart1 &"'; DELETE from responsetable where questiontableid in (SELECT questiontableid FROM questiontable where headtableid ='"& vart1 "&');DELETE from questiontable where headtableid ='"& vart1 &"'"
Jag ändrade på ordningen mellan dina delete-satser.
------------------ essentitia preter non sans multiplicandum
Så här ser hela koden ut, tar jag bort stängningen så här funkar den, inte annars.
vad gör jag för fel?
vart1 =request.querystring("id")
strconn = MM_forum_STRING
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open strconn
strsql = "DELETE from responsetable where questiontableid in (SELECT questiontableid FROM questiontable where headtableid ='"& vart1 &"');DELETE from questiontable where headtableid ='"& vart1 &"'; DELETE from headtable where headtableid ='"& vart1 &"'"
Set rs = conn.Execute(strsql)
response.redirect"admin.asp"