SetProperty<Type> methods for LCConnection

These methods assign a Connection property value as a specific data type. Data types supported include: Boolean, Currency, Datetime, Float, Int, Numeric, and Text.

Defined In

LCConnection

Syntax

Call lcConnection.SetPropertyBoolean (propertyToken, srcBoolean)

Call lcConnection.SetPropertyCurrency (propertyToken, srcCurrency)

Call lcConnection.SetPropertyDatetime (propertyToken, srcDatetime)

Call lcConnection.SetPropertyFloat (propertyToken, srcFloat)

Call lcConnection.SetPropertyInt (propertyToken, srcInt)

Call lcConnection.SetPropertyNumeric (propertyToken, srcNumeric)

Call lcConnection.SetPropertyStream (propertyToken, srcStream)

Parameters

Parameter

Description

propertyToken

Long. Token identifying the Connection property. See Appendix B for a list of tokens.

src<Type>

Value to assign to the Connection property.

Example

Option Public
Uselsx "*lsxlc" 

Sub Initialize
  Dim connect As New LCConnection ("db2")  
  Dim conFld As New LCField (LCTYPE_TEXT,1)
  Dim propName As String
  Dim propDate As New LCDateTime
  Dim propNumeric As New LCNumeric
  Dim propStrm As New LCStream (0, 0, LCTYPE_TEXT)
  Dim propCurr As New LCCurrency
  Dim propFloat As Double
  Dim propInt As Long
  Dim tokenId As Long
  Dim propType As Long
  Dim propFlags As Long

  ' set the appropriate properties to connect to DB2,
  ' note that you can also use dynamic properties to do this
  connect.Database = "Gold"
  connect.Userid = "JDoe"
  connect.Password = "xyzzy"

  Call connect.ListProperty (LCLIST_FIRST,_
  tokenId, propType, propFlags, propName)
  Do
    Set conFld = connect.GetProperty (tokenId)
    If (propFlags And LCPROPERTYF_READONLY) <> LCPROPERTYF_READONLY Then
      ' match the property to a datatype and set it
      Select Case propType
      Case LCTYPE_DATETIME:
        propDate.SetCurrent
        Call connect.SetPropertyDatetime (tokenId, propDate)
        Print propName  & " is now a datetime and contains " & propDate.text
      Case LCTYPE_NUMERIC:
        propNumeric.text = "100.0123456789"
        Call connect.SetPropertyNumeric (tokenId, propNumeric)
        Print propName  &  " is now a numeric and contains " & _ 
 propNumeric.text
      Case LCTYPE_TEXT:
        propStrm.text  = "a beautiful day"
        Call connect.SetPropertyStream (tokenId,  propStrm)
        Print propName & " is now text and contains " & propStrm.text
      Case LCTYPE_CURRENCY:
        propCurr.text = "140.10"
        Call connect.SetPropertyCurrency (tokenId, propCurr)
        Print propName & " is now currency and contains " & propCurr.text
      Case LCTYPE_FLOAT:
        Call connect.SetPropertyFloat (tokenId,  30000.456)
        Print propName & " is now a float and contains " & Cstr (30000.456)
      Case LCTYPE_INT:
        If (propFlags And LCPROPERTYF_BOOLEAN) Then
          Call connect.SetPropertyBoolean (tokenId, True)
          Print propName &  " is now an int and contains " & Cstr(True)
        Else
          Call connect.SetPropertyInt (tokenId, 123)
          Print propName &  " is now an int and contains " & Cstr(123)
        End If
      End Select
    End If
    Loop _
    While connect.ListProperty (LCLIST_NEXT, _
  tokenId, propType, propFlags, propName)
End Sub

Example Ouput

Database is now text and contains a beautiful day
Userid is now text and contains a beautiful day
Metadata is now text and contains a beautiful day
Index is now text and contains a beautiful day
MapByName is now an int and contains True
Writeback is now an int and contains True
Condition is now text and contains a beautiful day
StampField is now text and contains a beautiful day
BaseStamp is now a datetime and contains 09/08/1998 05:24:33.65 PM
MaxStamp is now a datetime and contains 09/08/1998 05:24:33.65 PM
Procedure is now text and contains a beautiful day
Owner is now text and contains a beautiful day
AlternateMetadata is now an int and contains True
CommitFrequency is now an int and contains 123
RollbackOnError is now an int and contains True
CreateMaxLogged is now an int and contains 123
NoJournal is now an int and contains True
CreateInDatabase is now text and contains a beautiful day
TraceSQL is now an int and contains True