tags:

views:

36

answers:

2

in my classic asp website, there is an objCMD variable being set to the value of Server.CreateObject("ADODB.Command"). i think that objCMD should be turned into a SqlCommand .NET object, but i need confirmation first. i'm still not sure what Server.CreateObject("ADODB.Command") is doing.

can someone explain Server.CreateObject() to me?

+3  A: 

Server.CreateObject creates a COM object from the named identifier, for use within asp.

The passed in string will identify what COM object needs to be created for use by asp (such as Msxml.DOMDocument for the XML parser, or an ADODB database command object, as in your example).

As you have guessed, the equivalent of ADODB.Command in .NET is the SqlCommand object.

Oded
+1  A: 

Server.CreateObject was essentially creating a server object of the type specified. In your case, it was an ADO command object.

With .Net, this has been replaced by the ADO.Net framework, which is much simpler to use. You will create a SqlCommand object, just as you had indicated, as well as a DataAdapter or DataReader object as well to work with the SqlCommand object.

Dillie-O
thanks for your answer. just beneath my "ADODB.Command" declaration, i have a "Server.CreateObject("ADODB.Recordset")" object. this is what i need to replace with a DataAdapter or DataReader object as you said right?
In the case of a Recordset, you'll want to use a DataTable if you're going to use the TableAdapter to retrieve/manipulate your data or may use non at all if you use the DataReader. The DataReader provides a "one time stream" of the record set results, one record at a time, so you can choose what to do with the data as you need.
Dillie-O