Is This Content Helpful?
We're glad to know this article was helpful.
When you create a database connection in ArcCatalog, you are asked whether you want to save the connection properties. If the properties are not saved, you are prompted to provide connection properties whenever you make a database connection. This article outlines how to force the same prompt programmatically.
Note: For more information on creating a UIControl, see the ArcGIS Desktop Help topic: 'Creating custom commands with VBA and UI Controls'
Code: Dim pWF As IWorkspaceFactory Dim pPropSet As IPropertySet Set pWF = New SdeWorkspaceFactory Set pPropSet = New PropertySet pPropSet.SetProperty "SERVER", "myserver" pPropSet.SetProperty "INSTANCE", "nnnn" ' ***** Omit references to SetProperty when you want to prompt for user input 'pPropSet.SetProperty "USER", "sde" 'pPropSet.SetProperty "PASSWORD", "sde" 'pPropSet.SetProperty "DATABASE", "db" 'SQL Server and Informix only 'pPropSet.SetProperty "VERSION", "SDE.DEFAULT" pWF.Open pPropSet, 0 MsgBox "Finished"
Note: Experiment with the code. Uncomment those lines of code which set the properties for which you don't wish to prompt the user. For example, to hard-code the version yet still force a prompt for User and Password, then uncomment the SetProperty for VERSION.