This project has moved and is read-only. For the latest updates, please go here.

Sql query to listbox using INAudioPlugin

Jun 3, 2014 at 5:10 PM
I can't for the life of me figure out how to get my sql query results to display on separate lines in the listbox on mainform. Without using the INAudioPlugin I can do this no problem but using this I can't seem to accomplish what I want. I can get my results to the listbox but all are on a single line. How can I accomplish this using the plugin?

In my mainform.cs I have the following:
    [ImportingConstructor]
    public MainForm([ImportMany] IEnumerable<AudioPlugin> content)
    {
        InitializeComponent();
        listBox.DisplayMember = "Name";
        foreach (var listing in content)
        {
            listBox.Items.Add(listing);
        }
    }
In my recordingpanel.cs I have the following:
  [Export(typeof(INAudioPlugin))]
    public class RecordingPanelPlugin : AudioPlugin
    {
        private string _customer { get; set; }

        public void ConnectionString()
        {
            using (var conn = new SqlCeConnection("Data Source=MyDatabase.sdf;Password=pass;Persist Security Info=True"))
            {
                conn.Open();
                var comm = new SqlCeCommand("SELECT * FROM main", conn);
                SqlCeDataReader reader = comm.ExecuteReader();

                while (reader.Read())
                {
                    _customer += (string)(reader["CustomerName"]);
                }
            }
        }


        public string Name
        {
            get
            {
                ConnectionString();
                return _customer;
            }
        }

        public Control CreatePanel()
        {
            return new RecordingPanel();
        }
    }
Please help. I have spent literally hours trying to figure this out. I have output the results to a listbox as well but when I try to use the plugin they still input in a single string. If I do a Console.WriteLine I see each result on a separate line as I expect.
Jun 3, 2014 at 10:53 PM
Edited Jun 4, 2014 at 8:34 PM
I guess I was rethinking this. I removed the Import/Export from each class and instead just decide to execute my query on the mainform.cs to populate the listbox. Then I pass my listbox.SelectedItem over to my recordingpanel.cs. Everything is working as expected now.
Marked as answer by doby48 on 6/4/2014 at 12:35 PM
Jun 4, 2014 at 8:33 PM
Edited Jun 4, 2014 at 8:34 PM
EDIT: Removed Duplicate Post