Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Con.Execute vs Rst.Open what's the difference

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I recently read a book that said to run an SQL statement use:

set Con=Server.CreateObject("ADODB.Connection")
Con.Open "DSN=AccessDSN"

set Rst=Server.CreateObject("ADODB.Recordset")
Rst.Open sqlStatement, Con


This seemed logical and made a lot of sense to me, but then it would not work in my code until I used:

set Con=Server.CreateObject("ADODB.Connection")
Con.Open "DSN=AccessDSN"

set Rst=Con.Execute(sqlStatement)

What is the difference?

And this may be related, I get an error when I use:

set Rst=Nothing
set Con=Nothing

I am concerned because I don't want the recordsets to eat up my memory.
 
What's the SQL statement?

Action queries (queries that don't return anything - typically INSERT/UPDATE/DELETE statements) are run using the Execute method of a Connection or Command object.

Queries that return something (typically SELECT statements) are run using the Open method of the Recordset object.

What's the error raised? Something on the
set Rst=Nothing
line I assume, given the
set Rst=Con.Execute(sqlStatement)
doesn't return anything (and also Rst was never declared).
<insert witticism here>
codestorm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top