Hello Team,
Please am working on Window Application and I have the following table tblProduct which contain the pName as product name , tblDetail contain qty, price and amount, and tblMain contain transaction date as mDate and when I call the data into dataGridView by clicking load buttong I get this error as shown in the screen shot, kindly help
private void btnLoadData_Click(object sender, EventArgs e) {
double _total = 0; int i = 0; dataGridView3.Rows.Clear(); con.Open(); cmd = new SqlCommand(@"select p.ProID, p.pName,d.price,d.qty,sum(d.amount) from tblDetails as d inner join tblProduct as p on d.ProductID=p.ProID where mDate between'%" + dtSales1.Value.ToString("dd-MM-yyyy") + "'and '" + dtSales1.Value.ToString("dd-MM-yyyy") + "%'group by p.pName, d.price, d.qty, d.amount", con); dr = cmd.ExecuteReader(); while (dr.Read()) { i += 1; _total += double.Parse(dr["amount"].ToString()); dataGridView3.Rows.Add(i, dr["ProID"].ToString(), dr["pName"].ToString(), Double.Parse(dr["price"].ToString()).ToString("#,##0.00"), dr["qty"].ToString(), Double.Parse(dr["amount"].ToString()).ToString("#,##0.00")); } dr.Close(); con.Close(); lblTotal.Text = _total.ToString("Ghc #,##0.00");
con.Open(); cmd = new SqlCommand("select isnull(sum(amount),0) from tblDetails where where mDate between'" + dtSales1.Value.ToString("dd-MM-yyyy") + "'and '" + dtSales2.Value.ToString("dd-MM-yyyy") + "'", con); lblTotal.Text = Double.Parse(cmd.ExecuteScalar().ToString()).ToString("#,##0.00"); con.Close();
}