Thursday, 19 December 2013

Data View row filter using data table

Data View row filter using data table

I have the following code which doesn't seem to work. In the Button_Click event I populate the datatble and display the results in a grid view.


SqlCommand cmd = new SqlCommand("Select inv_No,inv_Date,Project  from Invoice_Master", con);
            
SqlDataAdapter adp = new SqlDataAdapter(cmd);           
DataTable dtserch = new DataTable();        
adp.Fill(dtserch);         
DataView dv = dtserch.DefaultView;

//Inv_No filter
dv.RowFilter = "inv_No='" + CmbSSalesInvNo.Text + "'";



//Date Filter

//convert date format as server date format

if (txtFromDate != "" && txtToDate.Text != "")
   {
                fromdate = Convert.ToDateTime(txtFromDate .Text).ToString("MM-dd-yyyy");
                Todate = Convert.ToDateTime(txtToDate.Text).ToString("MM-dd-yyyy");
    }

dv.RowFilter = "ServiceInvoiceDate >= #" + fromdate + "# and ServiceInvoiceDate <= #" + Todate + "#";


//Filter data bind to gridview

DgvAllSalesInvoices.DataSource = dv;

SQL SERVER – Disk Space Monitoring – Detecting Low Disk Space on Server

CREATE PROCEDURE [CSMSDVLP].[DiskSpaceMonitor] @mailProfile nvarchar(500), @mailto nvarchar(4000), @threshold INT, @logfile nvarchar(40...