public void RetrieveProductPrice(String ID) { SqlConnection RetrieveProductPrice = new SqlConnection("Data Source=SELAKA\\SELA;Initial Catalog=SATHOSA;Integrated Security=True"); SqlCommand Select = new SqlCommand("Select Product_Selling_Price FROM Product Where Product_ID=@ID;", RetrieveProductPrice); //MessageBox.Show(""+ID); Select.Parameters.AddWithValue("@ID", ID); try { SqlDataReader DataReader2; RetrieveProductPrice.Open(); DataReader2 = Select.ExecuteReader(); while (DataReader2.Read()) { metroTextBox7.Text = DataReader2["Product_Selling_Price"].ToString(); } DataReader2.Close(); } catch (Exception ex) { MessageBox.Show("" + ex); } finally { RetrieveProductPrice.Close(); } }
public void BufferData(int highestRow) { if (!IsBufferMode) { var isStop = false; while (CachedResult.Rows.Count < highestRow && !isStop) { isStop = true; DataRow row = null; if (DataReader != null && DataReader.Read()) { row = CachedResult.NewRow(); CachedResult.Rows.Add(row); var count = DataReader.FieldCount; for (var i = 0; i < count; i++) { row[DataReader.GetName(i)] = DataReader.GetValue(i); } isStop = false; } if (DataReader2 != null && DataReader2.Read()) { if (row == null) { row = CachedResult.NewRow(); CachedResult.Rows.Add(row); } var count = DataReader2.FieldCount; for (var i = 0; i < count; i++) { row[DataReader2.GetName(i)] = DataReader2.GetValue(i); } isStop = false; } } } }
public void BufferData(int highestRow) { if (!IsBufferMode) { var isStop = false; if (DataReader2 == null) { while (CachedResult.Rows.Count < highestRow && !isStop) { isStop = true; DataRow row = null; if (DataReader != null && DataReader.Read()) { row = CachedResult.NewRow(); CachedResult.Rows.Add(row); var count = DataReader.FieldCount; for (var i = 0; i < count; i++) { row[DataReader.GetName(i)] = DataReader.GetValue(i); } isStop = false; } if (DataReader2 != null && DataReader2.Read()) { if (row == null) { row = CachedResult.NewRow(); CachedResult.Rows.Add(row); } var count = DataReader2.FieldCount; for (var i = 0; i < count; i++) { row[DataReader2.GetName(i)] = DataReader2.GetValue(i); } isStop = false; } } } else { string primaryKey = null; for (var i = 0; i < DataReader.FieldCount; i++) { for (var j = 0; j < DataReader2.FieldCount; j++) { if (DataReader.GetName(i) == DataReader2.GetName(j)) { primaryKey = DataReader.GetName(i); } } } while (CachedResult.Rows.Count < highestRow && !isStop) { isStop = true; DataRow row = null; if (DataReader != null && DataReader.Read()) { row = CachedResult.NewRow(); CachedResult.Rows.Add(row); var count = DataReader.FieldCount; for (var i = 0; i < count; i++) { row[DataReader.GetName(i)] = DataReader.GetValue(i); } isStop = false; } } DataTable dt1 = CachedResult.Copy(); CachedResult.Clear(); isStop = false; while (CachedResult.Rows.Count < highestRow && !isStop) { isStop = true; DataRow row = null; if (DataReader2 != null && DataReader2.Read()) { if (row == null) { row = CachedResult.NewRow(); CachedResult.Rows.Add(row); } var count = DataReader2.FieldCount; for (var i = 0; i < count; i++) { row[DataReader2.GetName(i)] = DataReader2.GetValue(i); } isStop = false; } } DataTable dt2 = CachedResult.Copy(); CachedResult.Clear(); var tables = new DataTable[] { dt1, dt2 }; CachedResult = MergeAll(tables.ToList(), primaryKey); } } }