Search This Blog

Monday, February 25, 2013

@@TRANCOUNT (SQL Server)

SQL Server > Built-In Functions > @@TRANCOUNT

Returns the number of BEGIN TRANSACTION statements that have occurred on the current connection.

Example:


PRINT @@TRANCOUNT
BEGIN TRAN --  The BEGIN TRAN statement will increment the  transaction count by 1.
PRINT @@TRANCOUNT
COMMIT     --  The COMMIT statement will decrement the  transaction count by 1.
PRINT @@TRANCOUNT

Result:
0
1
0




Thursday, February 7, 2013

SQL query result insert in temp table

SQL Server > Create dynamic temp table

Select into create dynamical temporary table

Example

SELECT
   *
into
   #t
FROM
  table




Call REST (C#)

C# > WebRequestMethods.Http.Get

WebRequestMethods.Http.Get: Represents an HTTP GET protocol method.

The GET method retrieves the information or entity that is identified by the URI of the request.

Example:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            string Uri = "Your Uri";
            String text;
            HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(Uri);
            myReq.Method = WebRequestMethods.Http.Get;
            myReq.Accept = "application/json";

            HttpWebResponse response = (HttpWebResponse)myReq.GetResponse();
            using (var sr = new StreamReader(response.GetResponseStream()))
            {
                text = sr.ReadToEnd();
            }
        }
    }
}







Location and Size (C#)

C# > Controls > Location and Size

Location

Gets or sets the coordinates of the upper-left corner of the control relative to the upper-left corner of its container.

Size

Gets or sets the height and width of the control.

Example

label1.Location = new Point(4, 302);
label1.Size = new Size(85, 13);






Add dynamic event to controls (C#)

C# > ComponentModelCancelEventHandler 

Delegates the method that handles a cancel event.

Example

Add dynamic event to TextBox


txtReportHeader.Validating += new CancelEventHandler(MyValidating);
private void MyValidating(object sender, CancelEventArgs e)
{
     // some validation
}







Set font bold label (C#)

C# > Drawing > Font > Bold

Bold indicates when Font is bold.

Example:
label1.Font = new System.Drawing.Font(label1.Font, FontStyle.Bold);