If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Close connection between calls

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-14-07, 10:58
andy1234567 andy1234567 is offline
Registered User
 
Join Date: Dec 2007
Posts: 4
Close connection between calls

Hi

Say that you have an application that makes a couple of calls to the same database (insert, uppdate and delete). Do I need to close the connection between every call or can I make them over the same connection?

I know that it is possible but cloud there be an issue in doing so?
Reply With Quote
  #2 (permalink)  
Old 12-18-07, 17:34
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
The general rule of thumb is: close connections as soon as you can.
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 12-19-07, 04:04
andy1234567 andy1234567 is offline
Registered User
 
Join Date: Dec 2007
Posts: 4
Yes, but if I’m going to transfer say 100 rows from one table to another that’s 100 connect and 100 close. It would be better if i cloud use the same connection, it would use less resources. But if in doing so it creates error of some sort than i must close it for every insert.

Anyone?
Reply With Quote
  #4 (permalink)  
Old 12-19-07, 08:20
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
You could move 100 rows from 1 table to another in one command...

Post yourQL/code
__________________
George
Twitter | Blog
Reply With Quote
  #5 (permalink)  
Old 12-20-07, 03:18
andy1234567 andy1234567 is offline
Registered User
 
Join Date: Dec 2007
Posts: 4
How can i do that?
Reply With Quote
  #6 (permalink)  
Old 12-20-07, 07:03
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
This should have read
Quote:
Originally Posted by georgev
Post yourQL/code
Post your SQL/code

Basically, I reckon you're using the following
Code:
INSERT INTO tableName(field1, field2) VALUES (value1, value2)
Which means you can only do one line at a time.

There is a lovely method you can use when transferring data from one table to another which goes a little something like this:
Code:
INSERT INTO tableName(field1, field2)
  SELECT otherTable.field1
       , otherTable.field2
  FROM   otherTable
  <optional where clause(s) etc>
__________________
George
Twitter | Blog
Reply With Quote
  #7 (permalink)  
Old 12-20-07, 09:08
andy1234567 andy1234567 is offline
Registered User
 
Join Date: Dec 2007
Posts: 4
Thanks! ill try that!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On