Using ADO`s Record Object with URLs - Opening the Connection with a Shorter String
(Page 6 of 6 )
The connection string derived from the Url.udl file is very long, but it is sufficient to use a shorter string such as the code shown in the next paragraph.
Private Sub Command0_Click()
Dim con As New ADODB.Connection
Dim rec As New ADODB.Record
Dim constr As String
constr = "Provider=MSDAIPP.DSO;" & _
"Data Source=http://hodentek/TestingService/HelloOra.asmx"
con.Open constr
rec.ActiveConnection = con
rec.Open
MsgBox ("It is open")
MsgBox (rec.ParentURL)
End Sub
A complete list of different ways to open the record, recordset, and connection objects is available here.
The Record object also opens with implicit reference to the MSDAIPP when the connection string is not explicitly provided, as in the following code:
Private Sub Command1_Click()
Dim rec As New ADODB.Record
rec.Open "", "URL=http://localhost/TestingService"
Dim feld As ADODB.Field
For Each feld In rec.Fields
Debug.Print feld.Name & "/" & feld.Value
Next
End Sub
The Field Name and Field Value from the above code will be as shown in the next paragraph (copied from the immediate window). In this case, the resource is the folder with a number of items referring to the default site. The DAV: items refer to the WebDAV which stands for Web Distributed Authoring and Versioning attributes.
RESOURCE_PARSENAME/ TestingService
RESOURCE_PARENTNAME/ http://localhost/
RESOURCE_ABSOLUTEPARSENAME/ http://localhost/TestingService
RESOURCE_ISHIDDEN/
RESOURCE_ISREADONLY/
RESOURCE_CONTENTTYPE/
RESOURCE_CONTENTCLASS/
RESOURCE_CONTENTLANGUAGE/
RESOURCE_CREATIONTIME/
RESOURCE_LASTACCESSTIME/
RESOURCE_LASTWRITETIME/
RESOURCE_STREAMSIZE/
RESOURCE_ISCOLLECTION/ True
RESOURCE_ISSTRUCTUREDDOCUMENT/
DEFAULT_DOCUMENT/ http://localhost/Default.htm;
http://localhost/Default.asp;
http://localhost/index.htm;
http://localhost/iisstart.asp;
RESOURCE_DISPLAYNAME/ TestingServic
RESOURCE_ISROOT/ False
RESOURCE_ISMARKEDFOROFFLINE/
RESOURCE_METATAGS/
RESOURCE_LISTBASETYPE/
DAV:name/ TestingService
DAV:parentname/ http://localhost/
DAV:displayname/ TestingService
DAV:iscollection/ True
DAV:isroot/ False
DAV:defaultdocument/ http://localhost/Default.htm;
http://localhost/Default.asp;
http://localhost/index.htm;
http://localhost/iisstart.asp;
Summary
The URL is only one way of opening a Record object where the record source is an URL. A Record object can also be opened where the source may take these different forms: a Command object, a SQL statement, a table name, or an open recordset object. These different ways are not discussed. Also not discussed are the Copy and Delete methods shown earlier. The Record object and the Recordset object, though not the same, are related. Since both of them have fields collection, one has to be careful when using these objects. The code in this tutorial may be used as is, making changes to the available URL.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |