or
I have a dataset that contains multiple tables in it. What I want to do is find a way to take the values(and when I say "values" I do mean the plural "values") from a column within one table of the dataset and display them in a textbox. When I try to feed the values into an arraylist the values do not display correctly in design time. (Just shows the namespace object in the preview tab of VisualStudio) When I add the values to a string, I get the last value in the column which doesn't help me but it at least means I can iterate through the column values. Any idea as to how to make this work? How to get all the values in the column and bind to a textbox value. Below is the code i'm trying to use.
-Jason
| SqlConnection connSomsys = new SqlConnection(@"Server=cmdivst004\Jason08;Integrated Security=false;Database=QuoteDB; Persist Security Info=True;User ID=cmdiapp;Password=adiadmin"); |
| SqlCommand selectCommand; |
| connSomsys.Open(); |
| selectCommand = new SqlCommand("sprocgetProductListQuoteTotals", connSomsys); |
| selectCommand.CommandType = CommandType.StoredProcedure; |
| SqlDataAdapter adapter = new SqlDataAdapter(selectCommand); |
| DataSet dataSet = new DataSet(); |
| adapter.Fill(dataSet); |
| ArrayList myAL = new ArrayList(); |
| DataTable tbl = dataSet.Tables[1]; |
| for (int i = 0; i < tbl.Rows.Count; i++) |
| { |
| DataRow myRow = tbl.Rows[i]; |
| myAL.Add(myRow["ProductList"].ToString()); |
| } |
| textBox4.Value = myAL.ToString(); |
| SqlConnection connSomsys = new SqlConnection(@"Server=cmdivst004\Jason08;Integrated Security=false;Database=QuoteDB; Persist Security Info=True;User ID=cmdiapp;Password=adiadmin"); |
| SqlCommand selectCommand; |
| selectCommand = new SqlCommand("sprocgetQuoteProductTotals", connSomsys); |
| selectCommand.CommandType = CommandType.StoredProcedure; |
| SqlDataAdapter adapter = new SqlDataAdapter(selectCommand); |
| DataSet dataSet = new DataSet(); |
| adapter.Fill(dataSet); |
| this.DataSource = dataSet; |
| this.DataMember = "Table"; |
| this.textBox3.Value = dataSet.Tables[1].Rows[0][0].ToString(); |
| int textbox1val; |
| int textbox3val; |
| textbox1val = Convert.ToInt32(this.textBox1.Value); |
| textbox3val = Convert.ToInt32(this.textBox3.Value); |
| decimal percent = (textbox1val * 100) / textbox3val; |
| string textbox4val = Convert.ToString(percent); |
| this.textBox4.Value = textbox4val; |