Chidiebere Mgbemena

Chidiebere Mgbemena

  • NA
  • 179
  • 14.2k

error in bill view/Print summary

May 25 2020 4:38 PM
Thanx for all the help guyz i appreciate, as i said earlier i am new to c# that is why i need your help with this project am working on.
 
I am trying to view bills and print summary but am getting this error, please help detect the problem.
 
Thanks
 
 
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Data;  
  5. using System.Drawing;  
  6. using System.Linq;  
  7. using System.Text;  
  8. using System.Threading.Tasks;  
  9. using System.Windows.Forms;  
  10. using System.Data.SqlClient;  
  11. namespace NSPM_Sales_Invoice  
  12. {  
  13. public partial class ViewBills : Form  
  14. {  
  15. SqlConnection con = new SqlConnection(Properties.Settings.Default.NSPM_Sales_InvoiceCon);  
  16. SqlCommand cmd;  
  17. SqlDataAdapter da;  
  18. DataTable dt;  
  19. public ViewBills()  
  20. {  
  21. InitializeComponent();  
  22. }  
  23. private void ViewBills_Load(object sender, EventArgs e)  
  24. {  
  25. con.Open();  
  26. da = new SqlDataAdapter("Select * from Tbl_HeaderData order by JobNo asc", con);  
  27. con.Close();  
  28. SqlCommandBuilder cb = new SqlCommandBuilder(da);  
  29. dt = new DataTable();  
  30. da.Fill(dt);  
  31. dataGridView1.DataSource = dt;  
  32. }  
  33. private void btnViewBills_Click(object sender, EventArgs e)  
  34. {  
  35. con.Open();  
  36. da = new SqlDataAdapter("Select * from Tbl_HeaderData where JobNo between '" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "'and'" + dateTimePicker2.Value.ToString("yyyy-MM-dd") + "'order by JobNo asc ", con);  
  37. DataSet ds = new DataSet();  
  38. da.Fill(ds, "Tbl_HeaderData");  
  39. dataGridView1.DataSource = ds.Tables["Tbl_HeaderData"];  
  40. con.Close();  
  41. }  
  42. }  
  43. } 

Answers (5)