I want to add many items after scan them one by one from database into datatable
public void CheckItem( string itemcode) { string constring = @"Data Source=.;Initial Catalog=pos;User id = sa;password=123"; SqlCommand objCmd = new SqlCommand(); objCmd.Parameters.Clear(); using (SqlConnection objCnn = new SqlConnection(constring)) { objCnn.Open(); using (objCmd = objCnn.CreateCommand()) { objCmd.CommandType = CommandType.Text; objCmd.CommandText = "SELECT * FROM Items where Item_Code=@Item_Code"; objCmd.Parameters.Add(new SqlParameter("@Item_Code", itemcode)); SqlDataReader myreader = objCmd.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(myreader); decimal sumprice=0; if (dt.Rows.Count <= 0) // here i want to add new item into datatable , after that bind the new item with items that i added before dt = objDT.NewRow(); dt.Columns.Add("", typeof(decimal)); dataGridView1.DataSource = dt; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)