To create a SimpleDBDS ADSI provider object, use the GetObject function, supplying the appropriate path syntax, as follows:
Set objectname = GetObject(“SimpleDBDS://path”)
For example, the following creates a read-only ADSI provider:
Set myProduct = GetObject("SimpleDBDS://RO/DSN=cs;UID=sa;PWD=/select sku, name, dept_name from clocktower_product, clocktower_dept where clocktower_product.dept_id = clocktower_dept.dept_id and sku = ?//Lor-842W")
The path syntax differs depending on whether the provider is configured as read-only or read/write.
When a SimpleDBDS object is created, or opened with the GetObject function, its properties are initialized from the database. You can refresh these values from the database using the GetInfo method, overwriting any changes you have made to the property values cached in the object.
You can use the Get method to retrieve the object properties, as in the following example:
Dim mySKU
mySKU = myProduct.Get("sku")
Alternately, you can retrieve the value using dot notation:
mySKU = myProduct.sku
If you have created a read/write provider, use the Put method to modify property values in the object.
myProduct.Put "sku", mySKU
Alternately, you can set values on the object using dot notation:
myProduct.sku = mySKU
The following built-in properties have specially defined values, and can be accessed only with Get and Put.
Use the SetInfo method to write property values from the object to the database. When you call SetInfo, only the properties that you changed in the object are written back to the database. If you do not call SetInfo, your changes will not be written to the database.
When you retrieve database properties into a SimpleDBDS object, the database is not locked while you are changing property values in the object. Other programs may make changes to values in the database after you have retrieved values and before you save them back into the database. The final values in the database will reflect the last change written. Your program should minimize the time between retrieving and saving values.
The following example creates a read/write SimpleDBDS object that enables access to a customer with the specified shopper ID in the customer database table. It then reads the value of the shopper_name
column for that record, and stores this value into the shopperName
variable. The example also shows how a new value can be stored into the variable, saved to the object with the Put method, and written back to the database with the SetInfo method:
Dim customer, shopperName
Set customer = GetObject("SimpleDBDS://RW/DSN=cs;UID=sa;PWD=/
vc30_shopper/shopper_id//////Q0H4SE915ASH2KC000Q79QB17E500439")
' Get the value from the object
shopperName = customer.GetEx "shopper_name"
' Get updated shopper name
' Put the value back in the object
customer.Put "shopper_name", updatedShopperName
' Save the changes back to the metabase
customer.SetInfo
The SimpleDBDS object’s Put, PutEx, and SetInfo methods do not support database tables containing fields of type TimeStamp. Instead, use the DateChanged argument in the Directory Services path for read/write access. This argument provides the same functionality as using TimeStamp fields (see SimpleDBDS Read/Write Path and Methods).