Friday, March 23, 2012

How to load a windows form from another windows form as a modal dialog box and put the child form in the center of the parent form?



  private void Form1_Load(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();
             form2 .StartPosition = FormStartPosition.CenterParent;
            form2.ShowDialog();
        }

Friday, March 16, 2012

Find the row count in SQL Server tables


SELECT
    [TableName] = so.name,
    [RowCount] = MAX(si.rows)
FROM
    sysobjects so,
    sysindexes si
WHERE
    so.xtype = 'U'
    AND
    si.id = OBJECT_ID(so.name)
GROUP BY
    so.name
ORDER BY
    2 DESC