2 Replies - 3380 Views - Last Post: 11 December 2009 - 03:08 AM Rate Topic: -----

#1 funnyinga  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 08-November 09

Windows Form Application - ComboBoxes and

Posted 10 December 2009 - 07:17 AM

Hello,
I'm trying to create a Windows Form Application that retrieves some data from any server, database and one particular table. To do this I want to use 3 separate combo boxes (see attached image) where I can select any SQL server (of the names in the combobox), and once that is done select any database on that selected server. Once the database is selected, I would like to be able to select a product type. The product type is a column name within a table titled "t_InFlowOutFlow_Data" that is in every database on every server. I would then like to retrieve this data (for the selected product type) and put the data in a datagrid view.

Attached Image

Here is the code for the comboboxes:
 this.SelectServerCB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.SelectServerCB.FormattingEnabled = true;
			this.SelectServerCB.Items.AddRange(new object[] {
			"HomeServer1",
			"HomeServer2",
			"OfficeServer1",
			"OfficeServer2",
			"OfficeServer3"});
			this.SelectServerCB.Location = new System.Drawing.Point(89, 32);
			this.SelectServerCB.Name = "SelectServerCB";
			this.SelectServerCB.Size = new System.Drawing.Size(175, 21);
			this.SelectServerCB.TabIndex = 0;
			this.SelectServerCB.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);



  this.SelectDatabaseCB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.SelectDatabaseCB.FormattingEnabled = true;
			this.SelectDatabaseCB.Items.AddRange(new object[] {
			""});
			this.SelectDatabaseCB.Location = new System.Drawing.Point(378, 32);
			this.SelectDatabaseCB.MaxDropDownItems = 100;
			this.SelectDatabaseCB.Name = "SelectDatabaseCB";
			this.SelectDatabaseCB.Size = new System.Drawing.Size(175, 21);
			this.SelectDatabaseCB.TabIndex = 3;
			this.SelectDatabaseCB.SelectedIndexChanged += new System.EventHandler(this.SelectDatabaseCB_SelectedIndexChanged);

 this.SelectDimensionCB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.SelectDimensionCB.FormattingEnabled = true;
			this.SelectDimensionCB.Location = new System.Drawing.Point(681, 32);
			this.SelectDimensionCB.Name = "SelectDimensionCB";
			this.SelectDimensionCB.Size = new System.Drawing.Size(175, 21);
			this.SelectDimensionCB.TabIndex = 4;
			this.SelectDimensionCB.SelectedIndexChanged += new System.EventHandler(this.SelectDimensionCB_SelectedIndexChanged);
			// 





I really don't know where to start with this. Can anyone please help?

Is This A Good Question/Topic? 0
  • +

Replies To: Windows Form Application - ComboBoxes and

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 5186
  • View blog
  • Posts: 13,914
  • Joined: 18-April 07

Re: Windows Form Application - ComboBoxes and

Posted 10 December 2009 - 09:08 PM

Well once you select the server, you have to have the application connect to that server and query all the databases available on that server (SQL statement "show databases"). Selecting the database will then give you access to the tables of that database at which time you select your table and pull out the rows using a data adapter. You can of course then bind your data grid control to that adapter.

You will need to establish a connection using a connection object, a dataadapter object to pull in queries and possibly a dataset to fill with results. You can get an idea how some of this works together using MSDN's tech pages for populating a dataset from a dataadapter.

Populating a DataSet from a DataAdapter - MSDN

I think explaining the whole ADO.NET process for this is beyond the scope of a forum thread. :)
Was This Post Helpful? 0
  • +
  • -

#3 funnyinga  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 08-November 09

Re: Windows Form Application - ComboBoxes and

Posted 11 December 2009 - 03:08 AM

Thanks. Greatly appreciated.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1