Solved

objConnextion.Execute and objRecordset.Open

Posted on 2004-08-18
9
520 Views
Last Modified: 2008-01-09
Hi Experts,

Delete, Update and Insert into SQL can be used in
objConnection.Execute
They can also be used in
objRecordset.Open?
If thay are, is there any difference?

Thank you in advance.
0
Comment
Question by:daveask
9 Comments
 
LVL 7

Expert Comment

by:j2nku
ID: 11828966
Don't know, usually i'm using
objRecordset.Open "INSERT INTO ...", objConnection, 3, 3
0
 
LVL 22

Assisted Solution

by:neeraj523
neeraj523 earned 80 total points
ID: 11829002
Hello

Normally we use objConnection.Execute for executing update/insert statements.. where we don't need the out put in a recordset.. or we don't need to manuplate recordset default properties.. but when using select statement with objConnection.Execute.. it will restrict recordset generated by this method to only to the default properties of the recordset.. it means.. u wont able to chnage the cursor type/location of the recordset.. which wont allow you to use recordCount, absolutePosition, paging etc very usefull and powerfull properties of the recordset..

Ofcourse using objConnection.Execute for select statement is very quick to code and also takes mariginal less resources.. only when you are not required any recordset defailt property..

make sense ??

neeraj523
0
 

Author Comment

by:daveask
ID: 11829434
Thank you very much!

In my case, I need to do
  strSQL = "Delete * From Table1"
  objConnection.Execute strSQL
  strSQL = "Insert Into Table1([IP]) Values('" & userIP & "')"
  objConnection.Execute strSQL
do you think I can lock like this:
  objRecordset.Open "Delete * From Table1", objConnection, 2, 2
  objRecordset.AddNew
  objRecordset.Fields("IP") = userIP

 
0
 

Author Comment

by:daveask
ID: 11829827
In my case, I need to do
  strSQL = "Delete * From Table1"
  objConnection.Execute strSQL
  strSQL = "Insert Into Table1([IP]) Values('" & userIP & "')"
  objConnection.Execute strSQL
do you think I can lock like this:
  objRecordset.Open "Delete * From Table1", objConnection, 2, 2
  objRecordset.AddNew
  objRecordset.Fields("IP") = userIP
   objRecordset.Update     'I forgot this in the last post
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 5

Expert Comment

by:darksinclair
ID: 11829923
that will work Daveask, just make sure when you are using objRecordset.Fields("IP") = userIP and then objRecordset.Update that you open your Recordset with the paramaters of 1,3.

ie : objRecordset.Open SQL, Conn, 1, 3

1, 3 will set the mode to allow you to update fields with a recordset.

Cheers,
0
 

Author Comment

by:daveask
ID: 11830227
darksinclair,

Thank you.
Why 2,2 not work? I need to lock the recordset.....
0
 
LVL 5

Expert Comment

by:darksinclair
ID: 11831271
Daveask, why do you need to lock the recordset?  Nobody is going to be able to access it since you close it right after you are done.  Other combinations than 1,3 are useable, however, to keep your position and for the best results I've found I use 1,3.  always works for me.

Cheers,  g/l in the rest of your coding!
0
 

Author Comment

by:daveask
ID: 11831338
darksinclair,

Yes, I have found a few people can access it!!! I might have 100 visitors at the "same" time!
0
 
LVL 5

Accepted Solution

by:
darksinclair earned 40 total points
ID: 11831667
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adoce31/html/ado30ref_28.asp

This should answer any questions you have,
Let me know if I can be of any more assistance,

Cheers,
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now