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.
ca开发者_如何学运维n someone explain Server.CreateObject()
to me?
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.
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.
精彩评论