ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old July 2nd, 2009, 01:09 PM
Cozilla Cozilla is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 89 Cozilla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 23 m 13 sec
Reputation Power: 3
Delete a row??

I have a report that queries a database and outputs a table. I would like to have the functionallity to delete a row of the table on the report as well as from the table in the database. What would be the best way to do this? A column with a delete button next to each row would be the best. How would I go about doing this? Here is my report code:

Code:
<%
 
 Dim oConn, oRS, strConn, URLRedirTo, strOut
 Dim strErrorMessage, sqltest
 Dim objCmd, objParam, strRs, strReturn
	
	Set oConn = Server.CreateObject ("ADODB.Connection")
 	oConn.Open "DSN=***;User Id=***; Password=***"
 
 	Set oRS=Server.CreateObject("ADODB.recordset")
	sqltext = "SELECT SessionId,StartTime,UserName,NASIP,NASIdentifier,"
	sqltext = sqltext & "FramedAddress,CallingStationId FROM ActiveSessions WHERE UserName NOT LIKE 'W00%'ORDER BY UserName;"
	oRS.Open sqltext, oConn
    
%>
<%
  
If oRS.EOF <> True Then

	Response.Write("<TABLE BORDER=""1"">")
	Response.Write("<THREAD><TR><TD><STRONG>SessionId</STRONG></TD>")
	Response.Write("<TD><STRONG>StartTime</STRONG></TD>")
	Response.Write("<TD><STRONG>UserName</STRONG></TD>")
	Response.Write("<TD><STRONG>NASIP</STRONG></TD>")
	Response.Write("<TD><STRONG>NASIdentifier</STRONG></TD>")
	Response.Write("<TD><STRONG>FramedAddress</STRONG></TD>")
	Response.Write("<TD><STRONG>CallingStationId</STRONG></TD></TR></THREAD>")
	
	
While Not oRS.EOF

    		Response.Write("<TR><TD>" & oRS("SessionId") & "</TD>" & vbCrLf)
    		Response.Write("<TD>" & oRS("StartTime") & "</TD>" & vbCrLf)
		Response.Write("<TD>" & oRS("UserName") & "</TD>" & vbCrLf)
		Response.Write("<TD>" & oRS("NASIP") & "</TD>" & vbCrLf)
		Response.Write("<TD>" & oRS("NASIdentifier") & "</TD>" & vbCrLf)
		Response.Write("<TD>" & oRS("FramedAddress") & "</TD>" & vbCrLf)
		Response.Write("<TD>" & oRS("CallingStationId") & "</TD>" & vbCrLf)
		Response.Write("</tr>" & vbCrLf)
		oRS.MoveNext
	wend
	Response.Write("</table>")

Else
	URLRedirTo = "NoUsersOnLine.html"
 	Response.Redirect URLRedirTo
End If

oRS.close : oConn.close
Set oRS = Nothing : Set oConn = Nothing 
Set objParam = Nothing : Set objCmd = Nothing
%>

Last edited by Cozilla : July 2nd, 2009 at 02:31 PM.

Reply With Quote
  #2  
Old July 2nd, 2009, 02:28 PM
Cozilla Cozilla is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 89 Cozilla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 23 m 13 sec
Reputation Power: 3
The unique identifier would be the sessionId. Just not sure how i would go about pulling that sessionId from the line then using it in the sql statement.

Reply With Quote
  #3  
Old July 3rd, 2009, 06:04 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 3,416 sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 23 h 57 m 27 sec
Reputation Power: 1800
Hi,

If you wanted to remove the rows from both the HTMl table and the database table in the clientside you would need to use AJAX.

Heres an example that doesnt use AJAX, instead, it just submits the form and passes the value of the SessionID in the form collection. The page then loops through the forms collection and deletes the corresponding record, then displays the html table minus the row.

Maybe not the best solution but may give you some ideas:
Code:
<%

 Dim oConn, oRS, strConn, URLRedirTo, strOut
 Dim strErrorMessage, sqltest
 Dim objCmd, objParam, strRs, strReturn

	Set oConn = Server.CreateObject ("ADODB.Connection")
 	oConn.Open "DSN=***;User Id=***; Password=***"

	For Each x in Request.Form
		If Left(x, 6) = "btnDel" Then

			sqltext = "DELETE FROM ActiveSessions WHERE SessionID = " & Mid(x, InStr(x, "|")+1)
			oConn.Execute(sql)
		End If
	Next

 	Set oRS=Server.CreateObject("ADODB.recordset")
	sqltext = "SELECT SessionId,StartTime,UserName,NASIP,NASIdentifier,"
	sqltext = sqltext & "FramedAddress,CallingStationId FROM ActiveSessions WHERE UserName NOT LIKE 'W00%'ORDER BY UserName;"
	oRS.Open sqltext, oConn

%>
<%
Response.Write("<form name=""delForm"" method=""post"" action=""yourpage.asp"">")
If oRS.EOF <> True Then

	Response.Write("<TABLE BORDER=""1"">")
	Response.Write("<THREAD><TR><TD width=""5%"">&nbsp;</TD><TD><STRONG>SessionId</STRONG></TD>")
	Response.Write("<TD><STRONG>StartTime</STRONG></TD>")
	Response.Write("<TD><STRONG>UserName</STRONG></TD>")
	Response.Write("<TD><STRONG>NASIP</STRONG></TD>")
	Response.Write("<TD><STRONG>NASIdentifier</STRONG></TD>")
	Response.Write("<TD><STRONG>FramedAddress</STRONG></TD>")
	Response.Write("<TD><STRONG>CallingStationId</STRONG></TD></TR></THREAD>")


While Not oRS.EOF

    		Response.Write("<TR><TD><input type=""submit"" value=""Delete"" name=""btnDel|" & oRS("SessionId") & """></TD>")
    		Response.Write("<TD>" & oRS("SessionId") & "</TD>" & vbCrLf)
    		Response.Write("<TD>" & oRS("StartTime") & "</TD>" & vbCrLf)
		Response.Write("<TD>" & oRS("UserName") & "</TD>" & vbCrLf)
		Response.Write("<TD>" & oRS("NASIP") & "</TD>" & vbCrLf)
		Response.Write("<TD>" & oRS("NASIdentifier") & "</TD>" & vbCrLf)
		Response.Write("<TD>" & oRS("FramedAddress") & "</TD>" & vbCrLf)
		Response.Write("<TD>" & oRS("CallingStationId") & "</TD>" & vbCrLf)
		Response.Write("</tr>" & vbCrLf)
		oRS.MoveNext
	wend
	Response.Write("</table>")

Else
	URLRedirTo = "NoUsersOnLine.html"
 	Response.Redirect URLRedirTo
End If
Response.Write("</form>")
oRS.close : oConn.close
Set oRS = Nothing : Set oConn = Nothing
Set objParam = Nothing : Set objCmd = Nothing
%>

Reply With Quote
  #4  
Old July 6th, 2009, 10:03 AM
Cozilla Cozilla is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 89 Cozilla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 23 m 13 sec
Reputation Power: 3
Quote:
Originally Posted by sync_or_swim
Hi,

If you wanted to remove the rows from both the HTMl table and the database table in the clientside you would need to use AJAX.

Heres an example that doesnt use AJAX, instead, it just submits the form and passes the value of the SessionID in the form collection. The page then loops through the forms collection and deletes the corresponding record, then displays the html table minus the row.

Maybe not the best solution but may give you some ideas:
Code:
<%

 Dim oConn, oRS, strConn, URLRedirTo, strOut
 Dim strErrorMessage, sqltest
 Dim objCmd, objParam, strRs, strReturn

	Set oConn = Server.CreateObject ("ADODB.Connection")
 	oConn.Open "DSN=***;User Id=***; Password=***"

	For Each x in Request.Form
		If Left(x, 6) = "btnDel" Then

			sqltext = "DELETE FROM ActiveSessions WHERE SessionID = " & Mid(x, InStr(x, "|")+1)
			oConn.Execute(sql)
		End If
	Next

 	Set oRS=Server.CreateObject("ADODB.recordset")
	sqltext = "SELECT SessionId,StartTime,UserName,NASIP,NASIdentifier,"
	sqltext = sqltext & "FramedAddress,CallingStationId FROM ActiveSessions WHERE UserName NOT LIKE 'W00%'ORDER BY UserName;"
	oRS.Open sqltext, oConn

%>
<%
Response.Write("<form name=""delForm"" method=""post"" action=""yourpage.asp"">")
If oRS.EOF <> True Then

	Response.Write("<TABLE BORDER=""1"">")
	Response.Write("<THREAD><TR><TD width=""5%"">&nbsp;</TD><TD><STRONG>SessionId</STRONG></TD>")
	Response.Write("<TD><STRONG>StartTime</STRONG></TD>")
	Response.Write("<TD><STRONG>UserName</STRONG></TD>")
	Response.Write("<TD><STRONG>NASIP</STRONG></TD>")
	Response.Write("<TD><STRONG>NASIdentifier</STRONG></TD>")
	Response.Write("<TD><STRONG>FramedAddress</STRONG></TD>")
	Response.Write("<TD><STRONG>CallingStationId</STRONG></TD></TR></THREAD>")


While Not oRS.EOF

    		Response.Write("<TR><TD><input type=""submit"" value=""Delete"" name=""btnDel|" & oRS("SessionId") & """></TD>")
    		Response.Write("<TD>" & oRS("SessionId") & "</TD>" & vbCrLf)
    		Response.Write("<TD>" & oRS("StartTime") & "</TD>" & vbCrLf)
		Response.Write("<TD>" & oRS("UserName") & "</TD>" & vbCrLf)
		Response.Write("<TD>" & oRS("NASIP") & "</TD>" & vbCrLf)
		Response.Write("<TD>" & oRS("NASIdentifier") & "</TD>" & vbCrLf)
		Response.Write("<TD>" & oRS("FramedAddress") & "</TD>" & vbCrLf)
		Response.Write("<TD>" & oRS("CallingStationId") & "</TD>" & vbCrLf)
		Response.Write("</tr>" & vbCrLf)
		oRS.MoveNext
	wend
	Response.Write("</table>")

Else
	URLRedirTo = "NoUsersOnLine.html"
 	Response.Redirect URLRedirTo
End If
Response.Write("</form>")
oRS.close : oConn.close
Set oRS = Nothing : Set oConn = Nothing
Set objParam = Nothing : Set objCmd = Nothing
%>


What you posted is exactly what i want it to do but i tried your code and in my logfile im getting the following error:

Code:
|16|800a01a8|Object_required:_' '


This is the code, line 16 is bolded. I tried replacing (sql) with (sqltext) and i get the same thing.

Code:
<%
 
 Dim oConn, oRS, strConn, URLRedirTo, strOut
 Dim strErrorMessage, sqltest
 Dim objCmd, objParam, strRs, strReturn
 
 For Each x in Request.Form
		If Left(x, 6) = "btnDel" Then

			sqltext = "DELETE FROM ActiveSessions WHERE SessionID = " & Mid(x, InStr(x, "|")+1)
			oConn.Execute(sql)
		End If
	Next
	
	Set oConn = Server.CreateObject ("ADODB.Connection")
 	oConn.Open "DSN=***;User Id=***; Password=***"
 
 	Set oRS=Server.CreateObject("ADODB.recordset")
	sqltext = "SELECT SessionId,StartTime,UserName,NASIP,NASIdentifier,"
	sqltext = sqltext & "FramedAddress,CallingStationId FROM ActiveSessions WHERE UserName NOT LIKE 'W00%'ORDER BY UserName;"
	oRS.Open sqltext, oConn
    
%>


Thanks!

Reply With Quote
  #5  
Old July 6th, 2009, 10:35 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 3,416 sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 23 h 57 m 27 sec
Reputation Power: 1800
Can you post the html generated by the code so I can see what the buttons name contains?

Also, Can you display the contents of the sql variable and post the results:
Code:
<%
If Left(x, 6) = "btnDel" Then
	sqltext = "DELETE FROM ActiveSessions WHERE SessionID = " & Mid(x, InStr(x, "|")+1)
	Response.Write(sql)
             Response.End
             oConn.Execute(sql)
End If

Reply With Quote
  #6  
Old July 6th, 2009, 10:52 AM
Cozilla Cozilla is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 89 Cozilla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 23 m 13 sec
Reputation Power: 3
Quote:
Originally Posted by sync_or_swim
Can you post the html generated by the code so I can see what the buttons name contains?

Also, Can you display the contents of the sql variable and post the results:
Code:
<%
If Left(x, 6) = "btnDel" Then
	sqltext = "DELETE FROM ActiveSessions WHERE SessionID = " & Mid(x, InStr(x, "|")+1)
	Response.Write(sql)
             Response.End
             oConn.Execute(sql)
End If


The sql variable isnt anything. The response write did not out put anything.

I have included the html output.
Attached Images
File Type: gif ScreenHunter_01 Jul. 06 10.47.gif (66.0 KB, 4 views)

Reply With Quote
  #7  
Old July 6th, 2009, 10:56 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 3,416 sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 23 h 57 m 27 sec
Reputation Power: 1800
Quote:
Originally Posted by Cozilla
The sql variable isnt anything. The response write did not out put anything.

I have included the html output.

My mistake, can you display the contents of your sql variable, is it sqlText?

Reply With Quote
  #8  
Old July 6th, 2009, 10:58 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 3,416 sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 23 h 57 m 27 sec
Reputation Power: 1800
With regards the html output, any chance you could view the source of the page and post the actual html code? I am only interested in the code behind the buttons so you can remove everything else so that you dont display any sensitive information.

Reply With Quote
  #9  
Old July 6th, 2009, 11:01 AM
Cozilla Cozilla is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 89 Cozilla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 23 m 13 sec
Reputation Power: 3
thats weird cuz the output is correct. I used the first row as shown in the pic i attached and this is what the response was:

Code:
DELETE FROM ActiveSessions WHERE SessionID = 000A3D0D

Reply With Quote
  #10  
Old July 6th, 2009, 11:04 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 3,416 sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 23 h 57 m 27 sec
Reputation Power: 1800
It worked for me when I tested it because my session ids were numeric, you would need to surround yours with single quotes:
Code:
sqltext = "DELETE FROM ActiveSessions WHERE SessionID = '" & Mid(x, InStr(x, "|")+1) & "' "

Reply With Quote
  #11  
Old July 6th, 2009, 11:09 AM
Cozilla Cozilla is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 89 Cozilla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 23 m 13 sec
Reputation Power: 3
just tried that too im still getting the same error.

Do you think it has something to do with the oConn?

Reply With Quote
  #12  
Old July 6th, 2009, 11:14 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 3,416 sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 23 h 57 m 27 sec
Reputation Power: 1800
Quote:
Originally Posted by Cozilla
just tried that too im still getting the same error.

Do you think it has something to do with the oConn?
It is important that you define your variable oConn and open the connection before you try and execute the sql statement, can you post your code as it stands so I can see what is going on?

Reply With Quote
  #13  
Old July 6th, 2009, 11:16 AM
Cozilla Cozilla is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 89 Cozilla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 23 m 13 sec
Reputation Power: 3
Quote:
Originally Posted by sync_or_swim
It is important that you define your variable oConn and open the connection before you try and execute the sql statement, can you post your code as it stands so I can see what is going on?


Code:
<%
 
 Dim oConn, oRS, strConn, URLRedirTo, strOut
 Dim strErrorMessage, sqltest
 Dim objCmd, objParam, strRs, strReturn
 
 For Each x in Request.Form
		If Left(x, 6) = "btnDel" Then

			sqltext = "DELETE FROM ActiveSessions WHERE SessionID = '" & Mid(x, InStr(x, "|")+1) & "' "
			oConn.Execute(sqltext)
		End If
	Next
	
	Set oConn = Server.CreateObject ("ADODB.Connection")
 	oConn.Open "DSN=**;User Id=**; Password=**"
 
 	Set oRS=Server.CreateObject("ADODB.recordset")
	sqltext = "SELECT SessionId,StartTime,UserName,NASIP,NASIdentifier,"
	sqltext = sqltext & "FramedAddress,CallingStationId FROM ActiveSessions WHERE UserName NOT LIKE 'W00%'ORDER BY UserName;"
	oRS.Open sqltext, oConn
    
%>

Reply With Quote
  #14  
Old July 6th, 2009, 11:18 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 3,416 sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 23 h 57 m 27 sec
Reputation Power: 1800
You need to declare the connection first:
Code:
<%
 
 Dim oConn, oRS, strConn, URLRedirTo, strOut
 Dim strErrorMessage, sqltest
 Dim objCmd, objParam, strRs, strReturn


 Set oConn = Server.CreateObject ("ADODB.Connection")
 oConn.Open "DSN=**;User Id=**; Password=**"
 
 
 For Each x in Request.Form
		If Left(x, 6) = "btnDel" Then

			sqltext = "DELETE FROM ActiveSessions WHERE SessionID = '" & Mid(x, InStr(x, "|")+1) & "' "
			oConn.Execute(sqltext)
		End If
	Next
	
 	Set oRS=Server.CreateObject("ADODB.recordset")
	sqltext = "SELECT SessionId,StartTime,UserName,NASIP,NASIdentifier,"
	sqltext = sqltext & "FramedAddress,CallingStationId FROM ActiveSessions WHERE UserName NOT LIKE 'W00%'ORDER BY UserName;"
	oRS.Open sqltext, oConn
    
%>
[/QUOTE]
Comments on this post
Cozilla agrees: Sync or swim is the best!!! Thanks again!!!

Reply With Quote
  #15  
Old July 6th, 2009, 11:21 AM
Cozilla Cozilla is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 89 Cozilla User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 23 m 13 sec
Reputation Power: 3
I moved the set oConn above the For Each and that was the trick

Sync or Swim thank you so much for all of your help!

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > Delete a row??


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
Stay green...Green IT