Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

need to display results from dataset select in second listbox

$
0
0

I am still pretty new to C# programming. Looking for a little help trying to display a second listbox, after selecting an item in first listbox, with the results of a select from an ODBC connection. My SELECT Command from the DataApdapter properties is:

SELECT Date_Added, Date_Issue, Date_Sch_Comp, Date_Work, First_Rt_Seq, Part_Nbr, Pkg_Assy_Line, Qty_To_Start, Status_Flag, Wo_Nbr FROM WO_PACK_SCHED WHERE (Pkg_Assy_Line = ?)

My code is

  private void Form1_Load(object sender, System.EventArgs e)
  {
   for (int I = 1; I <= 12; I++)
    lstBox1.Items.Add(I.ToString());

 
  }
  private void lstBox1_SelectedIndexChanged(object sender, System.EventArgs e)
  {
   int LnNbr = lstBox1.SelectedIndex + 1;
   string LnNbrKey = LnNbr.ToString();
   lstBox2.Items.Clear();
   odbcDataAdapter4.SelectCommand.Parameters["Pkg_Assy_Line"].Value = LnNbrKey;
   dataSet1.Clear();
   odbcDataAdapter4.Fill(dataSet1);
   lstBox2.DisplayMember = "Wo_Nbr";
   if (dataSet1.Tables[0].Rows.Count == 0)
   {
    MessageBox.Show ("No Work Orders exist for line " + LnNbrKey, "Alert", MessageBoxButtons.OK);
    lstBox2.Focus();
    return;
   }
  }

Thank You in Advance.

Ron


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>