[thelist] Insert Nothing

Ken Schaefer ken.schaefer at gmail.com
Tue Sep 28 01:09:03 CDT 2004


This is a OT to your original question, but you should *never* use the
code below (it's similar to the code that Ultradev used to

In your code you are:
a) opening a recordset to do an insert
b) you are implicitly opening an ADO connection. You do not have a
direct reference to that ADO connection, so you can't automatically
"release" to return it to the connection pool

If you really want to use a recordset to insert or update data, then you should:
a) explicty open a connection
b) SET the recordset's .ActiveConnection to the connection (if you
don't use SET, you are doing an implicit LET)

Personally I recommend using either an ADO command object -or- using
an SQL statement.

Some reading I recommend;

INFO: Connection Pool Management by ADO Objects Called From ASP
(notice the box in the first column, third row)

Pooling in the Microsoft Data Access Components:

Your code, if you use a recordsetm it should look like:

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open <conn string>

Set objRS = Server.CreateObject("ADODB.Recordset")
Set objRS.ActiveConnection = objConn  ' <- note Set

(otherwise, if you use a LET, you are accessing the *default property*
of objConn which is .ConnectionString, which results in an implicit
creation of another connection object).


On Mon, 27 Sep 2004 14:33:23 -0500, Rob Smith <rob.smith at thermon.com> wrote:
> >Why do you want to do this?
> I've got a site with multiple domain names pointing to the same site and the
> web traffic analyzing software does not know the difference of how people
> found the site as to which domain the used through the host headers.
> I just wanted to put in place a simple script that added a "tick mark" or
> row with a timestamp as the ticker when someone entered via a particular
> domain name...
> I ended up doing something like this:
> if Request.ServerVariables("HTTP_HOST") = "www.SomeDomainNameA.com" then
>        set Domains  = Server.CreateObject("ADODB.Recordset")
>        Domains.ActiveConnection = MM_web_request_STRING
>        Domains.CursorType = 0
>        Domains.CursorLocation = 2
>        Domains.LockType = 3
>        Domains.Source = "INSERT INTO Domains_comActivity (void) values
> ('')"
>        Domains.Open()
> else if
> The auto_increment is doing it's job as well as the timestamp is recording
> when. The only way I accomplished this was add a "void" column and inserted
> nothing.
> I was just hoping for a way to do this without involving that extra column.
> I'm sure there are a dozen different ways to accomplish this.
> Rob

More information about the thelist mailing list