- Feb 13, 2003
- 26,252
- 403
- 126
I'm writing classic ASP code and often have to do SQL queries of an Access database. I took this job over from another guy and the way the queries are written are as follows:
Set rsQuery = Server.CreateObject("ADODB.RecordSet")
strQuerySQL = "SELECT ot FROM atot"
rsQuery.Open strQuerySQL, Connection
Then you use the RecordSet object's MoveNext method and whatnot to go through the resulting records.
Then I came across another way of doing SQL queries like this:
strQuerySQL = "DELETE * FROM atot"
Connection.Execute(strQuerySQL)
Now, I am wondering which one is recommended? Neither one is harder to code or requires much more/less typing. I did notice that using the RecordSet.Open method allows you to use other methods like AddNew and such, where otherwise you would have to write an INSERT query. But, I am used to writing normal SQL queries and executing them as I've done a lot of that in PHP.
So, any thoughts? I suppose I'm leaning towards the RecordSet.Open method just because I can keep continuity in coding style, but I'm the only one who deals with the code and it doesn't matter to me. But, it might to the next person to have this job.
Set rsQuery = Server.CreateObject("ADODB.RecordSet")
strQuerySQL = "SELECT ot FROM atot"
rsQuery.Open strQuerySQL, Connection
Then you use the RecordSet object's MoveNext method and whatnot to go through the resulting records.
Then I came across another way of doing SQL queries like this:
strQuerySQL = "DELETE * FROM atot"
Connection.Execute(strQuerySQL)
Now, I am wondering which one is recommended? Neither one is harder to code or requires much more/less typing. I did notice that using the RecordSet.Open method allows you to use other methods like AddNew and such, where otherwise you would have to write an INSERT query. But, I am used to writing normal SQL queries and executing them as I've done a lot of that in PHP.
So, any thoughts? I suppose I'm leaning towards the RecordSet.Open method just because I can keep continuity in coding style, but I'm the only one who deals with the code and it doesn't matter to me. But, it might to the next person to have this job.