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
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace NSPM_Sales_Invoice
- {
- public partial class ViewBills : Form
- {
- SqlConnection con = new SqlConnection(Properties.Settings.Default.NSPM_Sales_InvoiceCon);
- SqlCommand cmd;
- SqlDataAdapter da;
- DataTable dt;
- public ViewBills()
- {
- InitializeComponent();
- }
- private void ViewBills_Load(object sender, EventArgs e)
- {
- con.Open();
- da = new SqlDataAdapter("Select * from Tbl_HeaderData order by JobNo asc", con);
- con.Close();
- SqlCommandBuilder cb = new SqlCommandBuilder(da);
- dt = new DataTable();
- da.Fill(dt);
- dataGridView1.DataSource = dt;
- }
- private void btnViewBills_Click(object sender, EventArgs e)
- {
- con.Open();
- 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);
- DataSet ds = new DataSet();
- da.Fill(ds, "Tbl_HeaderData");
- dataGridView1.DataSource = ds.Tables["Tbl_HeaderData"];
- con.Close();
- }
- }
- }