Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_ado_rds thread: Command Object


Message #1 by "Frank Normann" <fnormann@m...> on Thu, 22 Nov 2001 23:02:44
Hey all!!



I'm the lucky owner of Beginning Active Server Pages 3.0 but 

I indeed have some problems whit the Command Object described in the book.

It does not seem to work proberly??

Here is the script I made:



<%

Response.Buffer = True



akt = Request.QueryString("akt")

Set objComm = Server.CreateObject("ADODB.Command")

strConnect = "DBQ="& Server.MapPath(".") &"/fpdb/mdplan.mdb;

DefaultDir=DBQ="& Server.MapPath(".") &";Driver={Microsoft Access Driver

(*.mdb)};"

objComm.ActiveConnection = strConnect

objComm.CommandText = "SELECT * FROM mdplan"

objComm.CommandType = adCmdText        

Set objRS = objComm.Execute    

objRS.Filter = "Id = " & akt

If Not objRS.EOF Then

objRS.Delete

End If



objRS.Close

Set objRS = Nothing



Server.Transfer ("mdplan.asp")

%>



The QueryString is okay..i checked it by printing it out.

Im using IIS 5.0 and ADO 2.6



\Frank



Message #2 by wissamak@h... on Fri, 23 Nov 2001 07:00:42
Dear Frank,



It seems to me that the solution is as follows:



members of the querystring are strings so the variable 'akt' is a string and to 

concatenate it in the 'objRS.Filter' statement you need to do the following:



objRS.Filter = "Id = '" & akt & "'"



so you must enclose string variables with single quotes. (you do not need to do this 

for integers)



wissam



> Hey all!!

> 

> I'm the lucky owner of Beginning Active Server Pages 3.0 but 

> I indeed have some problems whit the Command Object described in the book.

> It does not seem to work proberly??

> Here is the script I made:

> 

> <%

> Response.Buffer = True

> 

> akt = Request.QueryString("akt")

> Set objComm = Server.CreateObject("ADODB.Command")

> strConnect = "DBQ="& Server.MapPath(".") &"/fpdb/mdplan.mdb;

> DefaultDir=DBQ="& Server.MapPath(".") &";Driver={Microsoft Access Driver

> (*.mdb)};"

> objComm.ActiveConnection = strConnect

> objComm.CommandText = "SELECT * FROM mdplan"

> objComm.CommandType = adCmdText        

> Set objRS = objComm.Execute    

> objRS.Filter = "Id = " & akt

> If Not objRS.EOF Then

> objRS.Delete

> End If

> 

> objRS.Close

> Set objRS = Nothing

> 

> Server.Transfer ("mdplan.asp")

> %>

> 

> The QueryString is okay..i checked it by printing it out.

> Im using IIS 5.0 and ADO 2.6

> 

> \Frank

> 

Message #3 by "Frank Normann" <fnormann@m...> on Fri, 23 Nov 2001 09:35:05
Well !!

objRS.Filter = "Id = " & akt ....Is a Integer (ex. 41)



I have had tried

objRS.Filter = "Id = '" & akt & "'" but it does not seem to be the bug??

















> Hey all!!

> 

> I'm the lucky owner of Beginning Active Server Pages 3.0 but 

> I indeed have some problems whit the Command Object described in the 

book.

> It does not seem to work proberly??

> Here is the script I made:

> 

> <%

> Response.Buffer = True

> 

> akt = Request.QueryString("akt")

> Set objComm = Server.CreateObject("ADODB.Command")

> strConnect = "DBQ="& Server.MapPath(".") &"/fpdb/mdplan.mdb;

> DefaultDir=DBQ="& Server.MapPath(".") &";Driver={Microsoft Access Driver

> (*.mdb)};"

> objComm.ActiveConnection = strConnect

> objComm.CommandText = "SELECT * FROM mdplan"

> objComm.CommandType = adCmdText        

> Set objRS = objComm.Execute    

> objRS.Filter = "Id = " & akt

> If Not objRS.EOF Then

> objRS.Delete

> End If

> 

> objRS.Close

> Set objRS = Nothing

> 

> Server.Transfer ("mdplan.asp")

> %>

> 

> The QueryString is okay..i checked it by printing it out.

> Im using IIS 5.0 and ADO 2.6

> 

> \Frank

> 

Message #4 by Fabio Ferreira Balota <ffbalota@u...> on Fri, 23 Nov 2001 09:37:06 -0200 (BRST)
Hi Frank, try this:



akt = Request.QueryString("akt")



Set objComm = CreateObject("ADODB.Connection")

objComm.ConnectionString = "DBQ="& Server.MapPath(".") &"/fpdb/mdplan.mdb; DefaultDir=DBQ="& Server.MapPath(".")
&";Driver={Microsoft Access Driver (*.mdb)};"

objComm.Open



sqlstring =  "SELECT * FROM mdplan"

Set objRS = CreateObject("ADODB.Recordset")

objRS.CursorLocation = 3

objRS.CursorType = 3

Set objRS.ActiveConnection = objComm 

objRS.Open sqlstring

 

objRS.Filter = "Id = " & CInt(Trim(akt))

If Not objRS.EOF Then objRS.Delete







Fabio Ferreira Balota

Message #5 by "Frank Normann" <fnormann@m...> on Fri, 23 Nov 2001 21:29:47
>Nope it did'nt work eighter??



This script were my original, but to try something different 

I tried to make a script using the Command Object,- but obviously

I not enable to get it to work??

Any ideas??



<%

Response.Buffer = True



Const adOpenKeyset = 1

Const adLockOptimistic = 3

akt = Request.QueryString("akt")

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

Conn.Open "DBQ="& Server.MapPath(".") &"/fpdb/mdplan.mdb; 

DefaultDir=DBQ="& Server.MapPath(".") &";Driver={Microsoft Access Driver 

(*.mdb)};"

Set fdRS = Server.CreateObject("ADODB.Recordset")

sletSQL = "DELETE FROM mdplan Where id="&akt

fdRS.Open sletSQL, Conn, adOpenKeyset, adLockOptimistic





Conn.Close

Set Conn = Nothing



Server.Transfer ("mdplan.asp")

%>



 

























Hi Frank, try this:

> 

> akt = Request.QueryString("akt")

> 

> Set objComm = CreateObject("ADODB.Connection")

> objComm.ConnectionString = "DBQ="& Server.MapPath(".") 

&"/fpdb/mdplan.mdb; DefaultDir=DBQ="& Server.MapPath(".") &";Driver

{Microsoft Access Driver (*.mdb)};"

> objComm.Open

> 

> sqlstring =  "SELECT * FROM mdplan"

> Set objRS = CreateObject("ADODB.Recordset")

> objRS.CursorLocation = 3

> objRS.CursorType = 3

> Set objRS.ActiveConnection = objComm 

> objRS.Open sqlstring

>  

> objRS.Filter = "Id = " & CInt(Trim(akt))

> If Not objRS.EOF Then objRS.Delete

> 

> 

> 

> Fabio Ferreira Balota

Message #6 by Fabio Ferreira Balota <ffbalota@u...> on Mon, 26 Nov 2001 09:14:45 -0200 (BRST)
Hi Frank, try this...



<%

Response.Buffer = True



Const adOpenKeyset = 1

Const adLockOptimistic = 3

akt = Request.QueryString("akt")

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

Conn.Open "DBQ="& Server.MapPath(".") &"/fpdb/mdplan.mdb; 

DefaultDir=DBQ="& Server.MapPath(".") &";Driver={Microsoft Access Driver 

(*.mdb)};"

sqlstring = "DELETE FROM mdplan Where id="&akt

Set objCmd = CreateObject("ADODB.Command")

objCmd.CommandText = sqlstring

objCmd.CommandType = adCmdText

Set objCmd.ActiveConnection = Conn 

objCmd.CommandTimeout = 0

objCmd.Execute , , adExecuteNoRecords

Set objCmd.ActiveConnection = Nothing

Set objCmd = Nothing



Conn.Close

Set Conn = Nothing



Server.Transfer ("mdplan.asp")

%>


  Return to Index