What s My Constant?

[Previous] [Next]

While this sample probably won't help you to learn more about ADO directly, I've leveraged this code as a tool in other projects and samples.

How many times have you checked the value of a property only to realize that you don't know what constant or combination of constants that value represents? If you were to check the Status property of the current record of the Recordset object to try to determine the cause of a conflict, would you rather see 2052 or adRecConcurrencyViolation + adRecDeleted?

The What's My Constant sample doesn't contain any forms. Instead, the sample is a series of class modules that you can compile into an ActiveX DLL. Once you have compiled the project, you can use the classes in your own projects. For example, say you had trapped for an optimistic updating conflict in your code and you wanted to understand what constant (or combination of constants) that value corresponds to. You could use this dynamic-link library in your project by adding a reference to the WhatsMyConstant library and then adding the following code:

 Set objTranslateConstant = New WhatsMyConstant.ADOConstants MsgBox objTranslateConstant.GetRecordStatus(rs.Status) 

Now, rather than knowing only that the Status property returned a value such as 2052, you would know the constant or combination of constants in the enumeration that correspond to that value. In this case the code would display the string "adRecConcurrencyViolation + adRecDeleted" in a dialog box.

The What's My Constant sample contains separate class modules for ADO, ADOX, JRO, and RDS constants. Each function within a class accepts a value from a particular constant enumeration and returns the name of the constant (or combination of constants) that the value passed into the function represents.

As someone who has learned a lot about ADO by trying to answer my own questions, I've found this code quite helpful. In fact, you'll see portions of the code in this sample appear in other samples on the companion CD. You're welcome to compile the library and use it in your own projects or simply copy portions of the code from the sample.



Programming ADO
Programming MicrosoftВ® ADO.NET 2.0 Core Reference
ISBN: B002ECEFQM
EAN: N/A
Year: 2000
Pages: 131
Authors: David Sceppa

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net