Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Performing multiple SQL statements against an access database


Message #1 by "Matthew Parlane" <matthew.parlane@t...> on Tue, 12 Dec 2000 00:15:17 -0000
Hi guys... need someone's help...



I am trying to perform a conditional update command against a recordset,

but the only way I can do it is to put it in the connection string when

setting up the recordset ie:



objrs.open "update table set field = 'whatever'"



This is not very useful, seeing as I want to pull only a number of fields

from the database ie:



objrs.open "select * from table where field = 'blah'"



All I need to be able to do is to pass an SQL command to the recordset...



I am reading Beginning Active Server Pages 3.0, and I cannot figure out

how to use the activeconnection thingy - I think this may be because I'm

connecting to the database in a non-standard way - it's an access 97

database, and this is how I connect:



<%

set db = server.CreateObject("ADODB.Connection") 

db.Open "Driver={Microsoft Access Driver

(*.mdb)};DBQ=d:\homepage\zevi\address\db1.mdb"

set peoplers = server.createobject("ADODB.Recordset")

%>



Any ideas?

Message #2 by "Ken Schaefer" <ken@a...> on Tue, 12 Dec 2000 11:50:32 +1100
If you are updating a database, you don't need a recordset object, because

you are not returning any records...just use the .execute method of your

connection object



<%

strSQL = "UPDATE table "

strSQL = strSQL & "SET field = 'whatver'"



objConn.execute(strSQL)

%>



is all you need.



Cheers

Ken





----- Original Message -----

From: "Matthew Parlane" <matthew.parlane@t...>

To: "ASP Databases" <asp_databases@p...>

Sent: Tuesday, December 12, 2000 11:15 AM

Subject: [asp_databases] Performing multiple SQL statements against an

access database





> Hi guys... need someone's help...

>

> I am trying to perform a conditional update command against a recordset,

> but the only way I can do it is to put it in the connection string when

> setting up the recordset ie:

>

> objrs.open "update table set field = 'whatever'"

>

> This is not very useful, seeing as I want to pull only a number of fields

> from the database ie:

>

> objrs.open "select * from table where field = 'blah'"

>

> All I need to be able to do is to pass an SQL command to the recordset...

>

> I am reading Beginning Active Server Pages 3.0, and I cannot figure out

> how to use the activeconnection thingy - I think this may be because I'm

> connecting to the database in a non-standard way - it's an access 97

> database, and this is how I connect:

>

> <%

> set db = server.CreateObject("ADODB.Connection")

> db.Open "Driver={Microsoft Access Driver

> (*.mdb)};DBQ=d:\homepage\zevi\address\db1.mdb"

> set peoplers = server.createobject("ADODB.Recordset")

> %>

>

> Any ideas?





Message #3 by "Matthew Parlane" <matthew.parlane@t...> on Tue, 12 Dec 2000 22:17:00 -0000
Hmm... thanks for that, it worked nicely...



one more question tho, when I run the objconn.execute, should I be running

that against that database (as in db.execute), or the recordset (as in

peoplers.execute)? (scroll down to see the way I've set it up)



cheers,



Big Matty



> If you are updating a database, you don't need a recordset object, because

> you are not returning any records...just use the .execute method of your

> connection object

> 

> <%

> strSQL = "UPDATE table "

> strSQL = strSQL & "SET field = 'whatver'"

> 

> objConn.execute(strSQL)

> %>

> 

> is all you need.

> 

> Cheers

> Ken

> 

> 

> ----- Original Message -----

> From: "Matthew Parlane" <matthew.parlane@t...>

> To: "ASP Databases" <asp_databases@p...>

> Sent: Tuesday, December 12, 2000 11:15 AM

> Subject: [asp_databases] Performing multiple SQL statements against an

> access database

> 

> 

> > Hi guys... need someone's help...

> >

> > I am trying to perform a conditional update command against a recordset,

> > but the only way I can do it is to put it in the connection string when

> > setting up the recordset ie:

> >

> > objrs.open "update table set field = 'whatever'"

> >

> > This is not very useful, seeing as I want to pull only a number of fields

> > from the database ie:

> >

> > objrs.open "select * from table where field = 'blah'"

> >

> > All I need to be able to do is to pass an SQL command to the recordset...

> >

> > I am reading Beginning Active Server Pages 3.0, and I cannot figure out

> > how to use the activeconnection thingy - I think this may be because I'm

> > connecting to the database in a non-standard way - it's an access 97

> > database, and this is how I connect:

> >

> > <%

> > set db = server.CreateObject("ADODB.Connection")

> > db.Open "Driver={Microsoft Access Driver

> > (*.mdb)};DBQ=d:\homepage\zevi\address\db1.mdb"

> > set peoplers = server.createobject("ADODB.Recordset")

> > %>

> >

> > Any ideas?



---

FREE WEB DEVELOPMENT CODE, CONTENT, AND INSIGHTS

IN YOUR INBOX!

Get the latest and best HTML, XML, and JavaScript tips, tools, and 

developments from the experts.  Sign up for one or more of EarthWeb's

FREE IT newsletters at http://www.earthweb.com today!  

---

You are currently subscribed to asp_databases as: $subst('Recip.EmailAddr')

To unsubscribe send a blank email to leave-asp_databases-$subst('Recip.MemberIDChar')@p2p.wrox.com

Message #4 by "Ken Schaefer" <ken@a...> on Wed, 13 Dec 2000 10:47:50 +1100
Matty,



.execute is a method of the ADO Connection object, not the Recordset object.

So:



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

objConn.Open strConnect



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



objConn.execute(strSQL)

' The above line will work



objRS.execute(strSQL)

' The above line will *not* work

' The Recordset has no .execute method



You might also want to look into some kind of naming scheme for your

objects/variables - at the very least preface your objects/variables with

some kind of designation indicating what they are, eg you can see above that

both the Connection object and the Recordet object are prefaced with obj.



Cheers

Ken







----- Original Message -----

From: "Matthew Parlane" <matthew.parlane@t...>

To: "ASP Databases" <asp_databases@p...>

Sent: Wednesday, December 13, 2000 9:17 AM

Subject: [asp_databases] Re: Performing multiple SQL statements against an

access database





> Hmm... thanks for that, it worked nicely...

>

> one more question tho, when I run the objconn.execute, should I be running

> that against that database (as in db.execute), or the recordset (as in

> peoplers.execute)? (scroll down to see the way I've set it up)

>

> cheers,

>

> Big Matty

>

> > If you are updating a database, you don't need a recordset object,

because

> > you are not returning any records...just use the .execute method of your

> > connection object

> >

> > <%

> > strSQL = "UPDATE table "

> > strSQL = strSQL & "SET field = 'whatver'"

> >

> > objConn.execute(strSQL)

> > %>

> >

> > is all you need.

> >

> > Cheers

> > Ken

> >

> >

> > ----- Original Message -----

> > From: "Matthew Parlane" <matthew.parlane@t...>

> > To: "ASP Databases" <asp_databases@p...>

> > Sent: Tuesday, December 12, 2000 11:15 AM

> > Subject: [asp_databases] Performing multiple SQL statements against an

> > access database

> >

> >

> > > Hi guys... need someone's help...

> > >

> > > I am trying to perform a conditional update command against a

recordset,

> > > but the only way I can do it is to put it in the connection string

when

> > > setting up the recordset ie:

> > >

> > > objrs.open "update table set field = 'whatever'"

> > >

> > > This is not very useful, seeing as I want to pull only a number of

fields

> > > from the database ie:

> > >

> > > objrs.open "select * from table where field = 'blah'"

> > >

> > > All I need to be able to do is to pass an SQL command to the

recordset...

> > >

> > > I am reading Beginning Active Server Pages 3.0, and I cannot figure

out

> > > how to use the activeconnection thingy - I think this may be because

I'm

> > > connecting to the database in a non-standard way - it's an access 97

> > > database, and this is how I connect:

> > >

> > > <%

> > > set db = server.CreateObject("ADODB.Connection")

> > > db.Open "Driver={Microsoft Access Driver

> > > (*.mdb)};DBQ=d:\homepage\zevi\address\db1.mdb"

> > > set peoplers = server.createobject("ADODB.Recordset")

> > > %>

> > >

> > > Any ideas?





--- 

FREE SOFTWARE DEVELOPMENT CODE, CONTENT, AND

INSIGHTS IN YOUR INBOX!

Get the latest and best C++, Visual C++, Java, Visual Basic, and XML tips, tools, and 

developments from the experts.  Sign up for one or more of EarthWeb?s

FREE IT newsletters at http://www.earthweb.com today!  

---

You are currently subscribed to asp_databases as: $subst('Recip.EmailAddr')

To unsubscribe send a blank email to leave-asp_databases-$subst('Recip.MemberIDChar')@p2p.wrox.com


  Return to Index