Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9197253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:01:44+00:00 2026-06-17T22:01:44+00:00

I need to use custom action to load items into combobox. UI.wxs: <Control Id=Server

  • 0

I need to use custom action to load items into combobox.

UI.wxs:

            <Control Id="Server" Type="ComboBox" X="30" Y="65" Width="200" Height="18" Property="DATABASE_SERVER">
                <ComboBox Property="DATABASE_SERVER">
                    <ListItem Text="[DATABASE_SERVER]" Value="[DATABASE_SERVER]" />
                </ComboBox>
                <Publish Property="LOGON_VALID" Value="0">1</Publish>
            </Control>

Custom Action

private static ActionResult EnumSqlServersIntoComboBox(Session session, IEnumerable<DataRow> rows)
{
    try
    {
        Debugger.Break();

        session.Log("EnumSQLServers: Begin");

        // Grab the combo box but make sure I'm getting only the one 
        // from WebAppInstallDlg.
        View view = session.Database.OpenView("SELECT * FROM ComboBox WHERE ComboBox.Property='DATABASE_SERVER'");
        view.Execute();

        Int32 index = 1;
        session.Log("EnumSQLServers: Enumerating SQL servers");
        foreach (DataRow row in rows)
        {
            String serverName = row["Name"].ToString();

            // Create a record for this web site. All I care about is
            // the name so use it for fields three and four.
            session.Log("EnumSQLServers: Processing SQL server: {0}", serverName);

            Record record = session.Database.CreateRecord(4);
            record.SetString(1, "DATABASE_SERVER");
            record.SetInteger(2, index);
            record.SetString(3, serverName);
            record.SetString(4, serverName);

            session.Log("EnumSQLServers: Adding record");
            view.Modify(ViewModifyMode.InsertTemporary, record);
            index++;
        }

        view.Close();

        session.Log("EnumSQLServers: End");
    }
    catch (Exception ex)
    {
        session.Log("EnumSQLServers: exception: {0}", ex.Message);
        throw;
    }

    return ActionResult.Success;
}

What I’m trying to achieve is to have a input text box with drop down arrow next to it with all loaded sql servers.
enter image description here

The only time sql servers get loaded into combobox is when I change my UI code to this:

<Control Type="ComboBox" Property="DATABASE_SERVER" Id="Server" Width="180" Height="16" X="110" Y="60" ComboList="yes" Sorted="yes" />

Notice ComboList=”yes” item. BUT this won’t work for me since this makes the combobox a drop down item and I want to be able to “TYPE” in alternate option.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:01:45+00:00Added an answer on June 17, 2026 at 10:01 pm

    I figured it out:

    Dialogs.wxs:

    ...                <Control Id="ServerLabel" Type="Text" X="20" Y="62" Width="80" Height="25" NoPrefix="yes" Text="SQL Database:" />
                    <Control Id="Server" Type="ComboBox" Height="16" Width="180" X="110" Y="60" Property="DATABASE_SERVER">
                        <ComboBox Property="DATABASE_SERVER">
                            <ListItem Text="[DATABASE_SERVER]" Value="[DATABASE_SERVER]" />
                        </ComboBox>
                        <Publish Property="LOGON_VALID" Value="0">1</Publish>
                    </Control>
    ...
    

    CustomAction:

        [CustomAction]
        public static ActionResult EnumerateSqlServers(Session session)
        {
            if (null == session)
            {
                throw new ArgumentNullException("session");
            }
    
            session.Log("EnumerateSQLServers: Begin");
    
            // Check if running with admin rights and if not, log a message to
            // let them know why it's failing.
            if (false == HasAdminRights())
            {
                session.Log("EnumerateSQLServers: " + "ATTEMPTING TO RUN WITHOUT ADMIN RIGHTS");
                return ActionResult.Failure;
            }
    
            ActionResult result;
    
            DataTable dt = SmoApplication.EnumAvailableSqlServers(false);
            DataRow[] rows = dt.Select(string.Empty, "IsLocal desc, Name asc");
            result = EnumSqlServersIntoComboBox(session, rows);
    
            session.Log("EnumerateSQLServers: End");
            return result;
        }
    
        private static ActionResult EnumSqlServersIntoComboBox(Session session, IEnumerable<DataRow> rows)
        {
            try
            {
                //Debugger.Break();
    
                session.Log("EnumSQLServers: Begin");
    
                View view = session.Database.OpenView("DELETE FROM ComboBox WHERE ComboBox.Property='DATABASE_SERVER'");
                view.Execute();
    
                view = session.Database.OpenView("SELECT * FROM ComboBox");
                view.Execute();
    
                Int32 index = 1;
                session.Log("EnumSQLServers: Enumerating SQL servers");
                foreach (DataRow row in rows)
                {
                    String serverName = row["Name"].ToString();
    
                    // Create a record for this web site. All I care about is
                    // the name so use it for fields three and four.
                    session.Log("EnumSQLServers: Processing SQL server: {0}", serverName);
    
                    Record record = session.Database.CreateRecord(4);
                    record.SetString(1, "DATABASE_SERVER");
                    record.SetInteger(2, index);
                    record.SetString(3, serverName);
                    record.SetString(4, serverName);
    
                    session.Log("EnumSQLServers: Adding record");
                    view.Modify(ViewModifyMode.InsertTemporary, record);
                    index++;
                }
    
                view.Close();
    
                session.Log("EnumSQLServers: End");
            }
            catch (Exception ex)
            {
                session.Log("EnumSQLServers: exception: {0}", ex.Message);
                throw;
            }
    
            return ActionResult.Success;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any need to use a custom buffer to either read or write
I need the ability to use custom locks at a session level (outside the
I need to create a custom json for the jit library. Should I use
I need to setup a custom action within WiX 3.0. I have the following
I'm still not totally clear on why I would need to build custom action
I need to use the same custom made block 2 times on the same
In Vim you often need to assign a key for your own custom action.
Related to: Accessing InstallShield "Support Files" from DTF (Managed Custom Action) I need to
I've got a custom component that I need to use if I create a
I am implementing a custom action for a WindowsCE CAB file, and I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.