Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Cant delete record from database


Message #1 by "Todd Schuman" <toddschuman@v...> on Thu, 3 Oct 2002 10:35:15 -0400
<% 
'remove the requested line from the order
dim LineNo
dim SessionID
dim oRS
dim SQL
LineNo = CLng(request.form("linenumber"))
SessionID = request.form("sessionid")
set oRS=Server.CreateObject("ADODB.Recordset")
 
'Create recordset for session
SQL = "SELECT * FROM ORD_LIN WHERE ORD_NO="&SessionID&" AND
ORD_LIN.ORD_LIN="&LineNo&";"
oRS.Open SQL, Conn, adOpenDynamic, adLockPessimistic
 
oRS.Delete adAffectCurrent
oRS.Update
%>
 
I have an include statement which connects to the database and the SQL
statement works fine as I am able to write the fields from the record
that I which to delete.  I can not figure out why it does not delete the
record from the database tho.  I have tried everything that I could
think of.  Any help would be greatly appreciated.
 
Thanks  

Message #2 by "Larry Woods" <larry@l...> on Thu, 3 Oct 2002 09:10:33 -0700
1. IF ORD_NO is text then you need " ' " around the SessionID
value.
2. Put spaces between ALL "&" characters.  You are asking for
trouble otherwise.
3. I have NEVER seen a recordset Update method called after a
Delete.  Probably no problem, but it is NOT necessary.

Larry Woods MCSD, MCT
l.woods, inc.


> -----Original Message-----
> From: Todd Schuman [mailto:toddschuman@v...]
> Sent: Thursday, October 03, 2002 7:35 AM
> To: Access ASP
> Subject: [access_asp] Cant delete record from database
>
>
> <%
> 'remove the requested line from the order
> dim LineNo
> dim SessionID
> dim oRS
> dim SQL
> LineNo = CLng(request.form("linenumber"))
> SessionID = request.form("sessionid")
> set oRS=Server.CreateObject("ADODB.Recordset")
>
> 'Create recordset for session
> SQL = "SELECT * FROM ORD_LIN WHERE ORD_NO="&SessionID&" AND
> ORD_LIN.ORD_LIN="&LineNo&";"
> oRS.Open SQL, Conn, adOpenDynamic, adLockPessimistic
>
> oRS.Delete adAffectCurrent
> oRS.Update
> %>
>
> I have an include statement which connects to the
> database and the SQL
> statement works fine as I am able to write the fields
> from the record
> that I which to delete.  I can not figure out why it
> does not delete the
> record from the database tho.  I have tried everything
> that I could
> think of.  Any help would be greatly appreciated.
>
> Thanks
>
>

Message #3 by "Darrell" <darrell@b...> on Thu, 3 Oct 2002 18:14:49 +0100
Hi Todd

I might be missing exactly what you are trying to do but why do you not
simply use SQL to delete the required record?

SQL = "DELETE * FROM ORD_LIN WHERE ORD_NO="&SessionID&" AND
ORD_LIN.ORD_LIN="&LineNo&";"


Cheers
Darrell

-----Original Message-----
From: Todd Schuman [mailto:toddschuman@v...]
Sent: 03 October 2002 15:35
To: Access ASP
Subject: [access_asp] Cant delete record from database


<%
'remove the requested line from the order
dim LineNo
dim SessionID
dim oRS
dim SQL
LineNo = CLng(request.form("linenumber"))
SessionID = request.form("sessionid")
set oRS=Server.CreateObject("ADODB.Recordset")

'Create recordset for session
SQL = "SELECT * FROM ORD_LIN WHERE ORD_NO="&SessionID&" AND
ORD_LIN.ORD_LIN="&LineNo&";"
oRS.Open SQL, Conn, adOpenDynamic, adLockPessimistic

oRS.Delete adAffectCurrent
oRS.Update
%>

I have an include statement which connects to the database and the SQL
statement works fine as I am able to write the fields from the record
that I which to delete.  I can not figure out why it does not delete the
record from the database tho.  I have tried everything that I could
think of.  Any help would be greatly appreciated.

Thanks



Message #4 by "Rob Parkhouse" <rparkhouse@o...> on Fri, 4 Oct 2002 00:39:24
> <% 
'remove the requested line from the order
dim LineNo
dim SessionID
dim oRS
dim SQL
LineNo = CLng(request.form("linenumber"))
SessionID = request.form("sessionid")
set oRS=Server.CreateObject("ADODB.Recordset")
 
'Create recordset for session
SQL = "SELECT * FROM ORD_LIN WHERE ORD_NO="&SessionID&" AND
ORD_LIN.ORD_LIN="&LineNo&";"
oRS.Open SQL, Conn, adOpenDynamic, adLockPessimistic
 
oRS.Delete adAffectCurrent
oRS.Update
%>
 
I have an include statement which connects to the database and the SQL
statement works fine as I am able to write the fields from the record
that I which to delete.  I can not figure out why it does not delete the
record from the database tho.  I have tried everything that I could
think of.  Any help would be greatly appreciated.
 
Thanks  



Is the conversion of request.form("linenumber") with CLng function 
necessary? You don't do it for sessionID and the SQL suggests both are 
numeric.

After the oRS.Open statement test the oRS.BOF property. You will probably 
find that no record is being returned and hence the oRS.Delete statement 
does nothing.

Good Luck

Rob

  Return to Index