Friday, 30 November 2012

ComboBox selectchanged to sort by Gridview




How to get combobox selectchanged Orderby low,High showing DatgridView  inC# WinForm from MS Access Database.


private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)

        {
            string selectString = "";
           
            //this.stockTableAdapter.FillBy(this.dB_BillingDataSet.stock);
            System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
            conn.ConnectionString = BillingApplication.Properties.Settings.Default.DB_BillingConnectionString;
            conn.Open();
            if (comboBox1.Text == "Lower")
                selectString = "SELECT product_id,product_quantity FROM stock ORDER BY product_quantity ASC";
            else
                selectString = "SELECT product_id,product_quantity FROM stock ORDER BY product_quantity DESC";
            int id = 0, product_quantity = 0, r = 0;
           int r1 = 0;
            OleDbCommand cmd = new OleDbCommand(selectString, conn);
            OleDbDataReader reader = cmd.ExecuteReader();
            if (reader.HasRows)
            {
                while (reader.Read())
                {

                    //stock query product id, quantity
                    //product  table just  name  where stock(product id)
                    selectString = "SELECT product_name FROM product WHERE(product_id = " + Convert.ToInt32(reader["product_id"]) + ")";
                    cmd = new OleDbCommand(selectString, conn);
                    OleDbDataReader reader1 = cmd.ExecuteReader();
                
                    string product_name = "";
                    if (reader1.HasRows)
                    {
                        while (reader1.Read())
                        {
                            id = Convert.ToInt32(reader["product_id"]);
                            product_name = reader1["product_name"].ToString();
                            productDataGridView.Rows.Add();
                            productDataGridView.Rows[r1].Cells[1].Value = reader1["product_name"].ToString();
                           
                            r1++;
                           
                        }
                    }
                    //add to grid
                    productDataGridView.Rows.Add();
                    productDataGridView.Rows[r].Cells[0].Value = reader["product_id"].ToString();
                  
                    productDataGridView.Rows[r].Cells[2].Value = reader["product_quantity"].ToString();

                    r++;

                }
            }
            }

When i select a sort by Lower in combobox it showing quantitiy low to High in Ascending order.



When i select a sort by Higher in combobox it showing quantitiy High to Low in Descending Order.



 

Thursday, 25 October 2012


SQL Server Get Created, Last Modified date of Stored Procedure or Table



Introduction:

In this article  will explain how to find or get last modified date and created date of stored procedure or table in sql server


To get created date or last modified date of stored procedure we need to write the query like this


SELECT name,type,type_desc,create_date,modify_date FROM sys.objects
WHERE type = 'P' AND name = 'YourProcedureName'

Here if you observe above query I mentioned type = 'P' this mean to identify stored procedure or table or function etc based on 'P','U','FN',etc…


Here type = 'P'   (Procedure)
        type = 'U'  (User Table)
        type = 'S'  (System Table)
        type = 'PK' (Primary Key)
        type = 'FN' (Scalar Function)

Suppose if we want to get modified or created date of table we need to mention type = 'U' and the query will be like this


SELECT name,type,type_desc,create_date,modify_date FROM sys.objects
WHERE type = 'U' AND name = 'YourTableName'

Example:


SELECT name,[type],type_desc,create_date,modify_date FROM sys.objects
WHERE [type] = 'P' AND name = 'GetUserDetails'

Output:


Friday, 5 October 2012



Microsoft Announces "TypeScript"


TypeScript is a new script language developed by Microsoft for application-scale JavaScript development. TypeScript extends JavaScript and compiles to plain JavaScript. Since it is JavaScript, it eventually can run in any browser, host or OS. It is an open source language.


"TypeScript is Open Source"

Microsoft is going open source and we have seen that when Visual Studio 2012 had support for HTML 5 and JavaScript. TypeScript is essentially an extension of that. If you are a Microsoft developer, you may want to get an early preview of TypeScript.

Microsoft has also announced a plug-in for Visual Studio 2012 so VS developer that you can download here.
TypeScript is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to clean, readable, standards-based JavaScript.
So, you may ask this question. Why do we need another JavaScript extended library? Well, TypeScript is much more than that. Today, JavaScript is limited in what you can do with it, but with TypeScript, developers can write complex and large applications. 

TypeScript extends JavaScript and compiles to plain JavaScript. 

SharePoint tenant opt-out for modern lists is retiring in 2019

We're making some changes to how environments can opt out of modern lists in SharePoint. Starting April 1, 2019, we're going to be...