Usage of conn.exe cute

Source: Internet
Author: User

Conn.exe cute usage



 

The usage of the conn.execute‑rs.openmethod is significantly different from that of the conn.execute‑rs.open‑command.exe cute method.

Generally, a record set can be used.

Set rsw.conn.exe cute (SQL)

Or directly

Rsw.conn.exe cute (SQL)

And

Set rs = server. Createobject ("ADODB. recordset ")
Rs. Open SQL, Conn, 0, 1, or Rs. Open SQL, Conn

In this case, open is usually a little better than the previous one.
(The command object is more flexible and the execution scope is wider)

Use conn.exe cute to directly execute the next set rs1_conn.exe cute (SQL)
However, the performance speed will be greatly reduced !!

It takes about 2 ~ 5 times !! (This is my own test in MSSQL loop for 1000 times. If you don't believe it, test it on your own right away.) So before executing the next rsw.conn.exe cute !! Be sure to close it! It's a good habit!

Rs. Open of a single object must be disabled before opening the next record set. Otherwise, an error occurs. The speed is basically the same in the case of SQL, Conn, 0, 1.

Therefore, I like to directly set a Createobject ("ADODB. recordser"). (If multiple record sets are not required to be staggered, no problem will occur !) Use it from the beginning !!!

Open and Close

The last set rs = nothing reaches the end!

More importantly, open provides a lot of attributes for flexible operation of database metadata !!
Open the treasure chest and see everything!
In many cases, open is not required!
Conn.exe cute wants to change the film to a black cloth ~~~ Sneaky ~~ Very single !!!

For example:

 

Rs1.open sql1, Conn, 0, 1
Rs. Open SQL, Conn, 1, 3
If RS (0) <0 then RS (0) = 0
RS (1) = aaa
RS (2) = bbb
Rs. Update' update record set written to database
Rs. addnew' adds a new record.
RS (0) = 1
RS (1) = ddd
RS (2) = KKK
Rs. Update
Id = RS (3) RS (s) 'the field is automatically numbered to get the automatic ID of the new record immediately // This is very common
Rs1.addnew new record for adding a connection to RS1 using ID rs
RS1 ("ID" = ID
RS1 (1) =...
..
Rs1.update
Rs1.close: Set RS1 = nothing
Rs. Close: Set rs = nothing

For specific operations, if conn.exe cute is used, four conn.exe cute

Conn.exe cute ("Update .."
Conn.exe cute ("insert into Table 1 :"
Rsw.conn.exe cute ("select new automatic ID"
Conn.exe cute ("insert into Table 2"

That method is logically organized and clear at a glance

There is also an interesting way to use recordset open record !!
I think it's a bit confusing.

 

Set rs = server. Createobject ("ADODB. recordset"
Set rs = server. Createobject ("ADODB. recordset"
Rs. Open sql1, Conn
Rs. Open sql2, Conn

This is to set two objects with the same name at the same time to open two record sets, and it is available!
'As long as the retrieved column name conforms to the metadata of these two sets of records
'Operation is normal !!
Extended

 

Set rs = server. Createobject ("ADODB. recordset"
Set rs = server. Createobject ("ADODB. recordset"
Set rs = server. Createobject ("ADODB. recordset"
Set rs = server. Createobject ("ADODB. recordset"
Rs. Open sql1, Conn
Rs. Open sql2, Conn
Rs. Open sql3, Conn
Rs. Open sql4, Conn

I have not tried more than two Rs with the same name !! It seems a bit similar to querying with SQL and then opening the record set ~~~ I used this before !! It should not be dazzling !! When and when?

With personal experience, I feel like: If you only need to touch the database, execute; if you want to perform complex operations on the database! Rs. Open is recommended.

 

How can I determine whether conn. Execute is successful or failed?

<%
Dim SQL
SQL = "select * from table"
On Error resume next
Conn.exe cute (SQL)
If err. Number = 0 then
Response. Write "successful! "
Else
Response. Write "failed"
End if
%>


Usage of conn.exe cute

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.