Ask a Question related to ASP Database, Design and Development.
-
nick #1
ASP (not Asp.Net) database best practice?
Will the object variables of
Connection, - Server.CreateObject("ADODB.Connection")
Recordset - Server.CreateObject("ADODB.Recordset")
and Command - Server.CreateObject("ADODB.Command")
be automatically released after the asp page finished running or error
exception (e.g. the database get down)?
I've the following function:
function openRS(conn, strCmd, item)
{
var cmd = Server.CreateObject("ADODB.Command")
var rs = Server.CreateObject("ADODB.Recordset")
rs.CursorType = adOpenForwardOnly
rs.LockType = adLockReadOnly
cmd.ActiveConnection = conn
cmd.CommandText = strCmd
cmd.CommandType = adCmdStoredProc
// Parameter pItem
var param = cmd.CreateParameter("@pItem",adVarChar,adParamInpu t,50,"")
cmd.Parameters.Append(param)
cmd.Parameters("@pItem") = item
rs.Open(cmd)
return rs
}
For example, if I never do "cmd = null" right after rs.Open(cmd), can it
causes problem? or ASP will automatically release it after run or error
exception?
nick Guest
-
best practice / tips
What are the best practices for setting up a 3d game? (stripping the programming for the most part) is it best to make one w3d with everything... -
Best practice for login screen using database
I have an c# as.net app that check if the user exist in a USERS table, that part is ok but now I need to pass the user ID no the next page beacuse... -
Best practice in postgres
Hi All, I'm new to postgres, so I need your help. We are in the process of migrating from oracle to postgres. DB size is about 400gb. My... -
WS-Security Best Practice?
I'm new to Webservices, but nonetheless have taken the leap! I have a ws I'm writing that will be used in a subscription. Nothing huge or... -
best practice question regarding AspState database for sessions
Quick question regarding best practices for using the AspState database for storing session variables in .NET web applications. I know I need to... -
Bob Barrows [MVP] #2
Re: ASP (not Asp.Net) database best practice?
nick wrote:
See> Will the object variables of
>
> Connection, - Server.CreateObject("ADODB.Connection")
> Recordset - Server.CreateObject("ADODB.Recordset")
> and Command - Server.CreateObject("ADODB.Command")
>
> be automatically released after the asp page finished running or error
> exception (e.g. the database get down)?
>
[url]http://blogs.msdn.com/ericlippert/archive/2003/09/17/53038.aspx[/url]
and
[url]http://blogs.msdn.com/ericlippert/archive/2004/04/28/122259.aspx[/url]
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Bob Barrows [MVP] Guest
-
nick #3
Re: ASP (not Asp.Net) database best practice?
Bob Barrows [MVP] wrote:
Thanks.> nick wrote:
>>>>Will the object variables of
>>
>>Connection, - Server.CreateObject("ADODB.Connection")
>>Recordset - Server.CreateObject("ADODB.Recordset")
>>and Command - Server.CreateObject("ADODB.Command")
>>
>>be automatically released after the asp page finished running or error
>>exception (e.g. the database get down)?
>>
>
> See
> [url]http://blogs.msdn.com/ericlippert/archive/2003/09/17/53038.aspx[/url]
> and
> [url]http://blogs.msdn.com/ericlippert/archive/2004/04/28/122259.aspx[/url]
>
>
So according to the links. I needn't do
cmd = null
in my example.
And I even needn't worry about using Jscript's
try {... database }
Finally { code to close connection, release database objects....}
to handle exceptions of database?
nick Guest
-
Bob Barrows [MVP] #4
Re: ASP (not Asp.Net) database best practice?
nick wrote:
It can't hurt, but is probably unnecessary.> Bob Barrows [MVP] wrote:
>>>> nick wrote:
>>>>>>> Will the object variables of
>>>
>>> Connection, - Server.CreateObject("ADODB.Connection")
>>> Recordset - Server.CreateObject("ADODB.Recordset")
>>> and Command - Server.CreateObject("ADODB.Command")
>>>
>>> be automatically released after the asp page finished running or
>>> error exception (e.g. the database get down)?
>>>
>>
>> See
>> [url]http://blogs.msdn.com/ericlippert/archive/2003/09/17/53038.aspx[/url]
>> and
>> [url]http://blogs.msdn.com/ericlippert/archive/2004/04/28/122259.aspx[/url]
>>
>>
> Thanks.
>
> So according to the links. I needn't do
> cmd = null
> in my example.
You should always explicitly close and destroy your ADO recordsets and>
> And I even needn't worry about using Jscript's
> try {... database }
> Finally { code to close connection, release database objects....}
> to handle exceptions of database?
connections (make sure you digest the part about circular references - child
objects should be cleaned before parent objects. Failure to adhere to this
can lead to memory leaks that can crash IIS) as early as possible to allow
the connections to go back into the connection pool to be used by other
threads. I would not wait until a Finally block to close them if there will
be a large amount of code to run before the Finally block is reached. One of
the main points made in the second link is the need/desirability to free
expensive resources as early as possible. This consideration should not be
ignored.
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Bob Barrows [MVP] Guest



Reply With Quote

