executing a db command in asp

B

Brian

hi,

when i want to do an action to the database i am using the command

Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("photoalbum.mdb") & ""
Set RS1 = myConn.Execute(SQL1)

is there something else i can use if it is only an INSERT statement in the
sql because i dont actually need to create a recordset ?

Brian
 
B

Bob Barrows

Brian said:
hi,

when i want to do an action to the database i am using the command

Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("photoalbum.mdb") & ""
Set RS1 = myConn.Execute(SQL1)

is there something else i can use if it is only an INSERT statement
in the sql because i dont actually need to create a recordset ?

Brian

Absolutely:

myConn.Execute SQL1,,129

The 129 is the result of the addition of 2 constants:

1 - adCmdText - Tells ADO that you are executing a sql string - you should
use this setting when opening the recordset as well:
Set RS1 = myConn.Execute(SQL1,,1)

128 - adExecuteNoRecords - Tells ADO that it does not have to construct a
recordset object since the query being executed does not return records. If
you do not specify this setting, ADO will waste time and resources creating
a recordset object that will never be used.

HTH,
Bob Barrows
 
B

Brynn

CLEAN, QUICK, IN AND OUT OF DATABASE !!!

Seriously ... checkout my DBConn.asp scripts at ...

http://www.coolpier.com/

click on Coolpier Scripts link, then on DBConn.asp, then on Code

I would put the full path, but I am making final adjustments to the
layout of my entire website, and the path will be changing for the
last time within the next 2 weeks. ((I am then creating a nav.asp page
to keep track of my scripts ... so if I change structure ever again in
the life of the page, the nav.asp page will be changed .. and any
posts I have on the group will still have good link))

All recordsets are turned into 2-dimensional arrays using getrows ...
clean, quick, in and out of database. since performance wise/thread
wise I believe it is better to get your rs into an array, and
seperately execute updates to it ... this I think is one of the best
ways generally.



<!-- #include virtual="/coolpier_scripts/_database_tools/DBConn.asp"
-->

<%
Dim yourSQL, yourArray, yourPagingArray

cp_TheConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};
DBQ=" & Server.MapPath("photoalbum.mdb") & ";"


Call cp_DBConn("open")

'//INSERT, UPDATE, DELETE, or SP not returning rs
Call cp_SqlExecute("insert into table1 ('someValue') value
('something') where userID = 'someID';")

'// SELECT or SP returning rs
yourArray = cp_SqlArray("Select this from that;")

'// SELECT or SP returning rs ... PAGING (page2/20per page example
below)
yourPagingArray = cp_SqlArray_Paging("Select this from that where
theother = 'somthing';", 2, 20)


Call DBConn("close")

'// AFTER DB CLOSED ... THEN mess with displaying the data in your
array!!!
%>


Brynn
www.coolpier.com


hi,

when i want to do an action to the database i am using the command

Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("photoalbum.mdb") & ""
Set RS1 = myConn.Execute(SQL1)

is there something else i can use if it is only an INSERT statement in the
sql because i dont actually need to create a recordset ?

Brian

Brynn
www.coolpier.com

I participate in the group to help give examples of code.
I do not guarantee the effects of any code posted.
Test all code before use!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top