How to set "Use SQL Server Authentication" using an ActiveX Script

  • Hi there,

    I wanted to use an ActiveX Script to select the "Use SQL Server Authentication" radio button in a Microsoft OLE DB Provider for SQL Server object. At first I tried something like:

    dim objConn

    objConn = DTSGlobalVariables.Parent.Connections("MyDatabase")

    objConn.UserID = DTSGlobalVariables("gUserID").Value

    objConn.Password = DTSGlobalVariables("gPassword").Value

    and I expected this to automatically select the "Use SQL Server Authentication" radio button with the Username and Password text fields in the Microsoft OLE DB to be set, but it didn't.

    What's wrong? what property name should I have used? or should it be done another way?

  • I believe this will do the trick.

    For SQL Auth

    objConn.Properties("UseTrustedConnection").value = 0

    For NT Auth

    objConn.Properties("UseTrustedConnection").value = -1

  • Wow! it worked! thanks so much

  • Just so you know if the future some of the extra settings not as direct properties are generally reachable thru the .Properties property. To get the right names use Disconnected Edit in DTS and they are at the top level of the object. Disconnected edit is extremely usefull to find these items and see what values and datatypes may be supported (you sometimes have to play with the object to see what all changes to find the right values).

  • whoa, I just found the Disconnected Edit, didn't know there was such a thing... I don't think these are found in Books Online which made it very difficult for me to know the properties. Thanks for the tip, this is very helpful and essential

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply