Tuesday, August 7, 2012

Query to know Foreign key (FK) column in your database MSSQL

SELECT f.name AS ForeignKey,
OBJECT_NAME(f.parent_object_id) AS TableName,
COL_NAME(fc.parent_object_id,
fc.parent_column_id) AS ColumnName,
OBJECT_NAME (f.referenced_object_id) AS ReferenceTableName,
COL_NAME(fc.referenced_object_id,
fc.referenced_column_id) AS ReferenceColumnName
FROM sys.foreign_keys AS f
INNER JOIN sys.foreign_key_columns AS fc
ON f.OBJECT_ID = fc.constraint_object_id

Query to know Primary key column in your database MSSQL


Query to know Primary key column in your database MSSQL...

SELECT i.name AS IndexName,
OBJECT_NAME(ic.OBJECT_ID) AS TableName,
COL_NAME(ic.OBJECT_ID,ic.column_id) AS ColumnName
FROM sys.indexes AS i
INNER JOIN sys.index_columns AS ic
ON i.OBJECT_ID = ic.OBJECT_ID
AND i.index_id = ic.index_id
WHERE i.is_primary_key = 1 order by OBJECT_NAME(ic.OBJECT_ID)

Query to know identity column in your database MSSQL



Query to know identity column in your database MSSQL

select COLUMN_NAME, TABLE_NAME
from INFORMATION_SCHEMA.COLUMNS
where TABLE_SCHEMA = 'dbo'
and COLUMNPROPERTY(object_id(TABLE_NAME), COLUMN_NAME, 'IsIdentity') = 1 order by TABLE_NAME

Wednesday, April 20, 2011

code for swap Silverlight xap in html


  <script type="text/javascript" src="Silverlight.js"></script>
<script type="text/javascript">
        var IsLSC = true;
      // function create Object block inside Div tag
        function CreateSilverlightMenuTree(XapPath) {
            var userDetails = "";
            var objectValue = Silverlight.createObject(
                "/ClientBin/" + XapPath,  // source
               null,  // parent element
                "slPlugin",  // id for generated object element
                {
                width: "100%", height: "100%", background: "transparent", windowless: "true",
                version: "5.0.60401.0"
            }, { onError: onCustomError, onLoad: onCustomLoad },
              "userData=" + userDetails,
            "context"    // context helper for onLoad handler.
            );
            var divObj = document.getElementById("silverlightControlHost");
            divObj.innerHTML = objectValue;
        }
        function onCustomError() {
            window.status += " Error in loading window";
        }
        function onCustomLoad() {
            window.status += " Window loaded";
        }
//function  swap between two xap file dynamically 
        function SwitchXap() {
            var paramObj= "";
            if (IsLSC) {
                paramObj = "LSC.xap";
                IsLSC = false;
              }
            else {
                paramObj = "SilverlightNetwork.xap";
                IsLSC = true;
            }
            CreateSilverlightMenuTree(paramObj);
        }
    </script>

</head>
<body>
    <form id="form1" runat="server" style="height:100%">
    <input id="Button1" type="button" value="Swap" onclick="SwitchXap()" />
    <div id="silverlightControlHost">
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
 <param id="paramXap" name="source" value="ClientBin/SilverlightNetwork.xap"/>
 <param name="onError" value="onSilverlightError" />
 <param name="background" value="white" />
 <param name="minRuntimeVersion" value="5.0.60401.0" />
 <param name="autoUpgrade" value="true" />

Wednesday, March 2, 2011

Call Scriptable Methods from JavaScript with Silverlight

Here is code snippet  to be written on html page










and here is code snippet to be written on xmal Page code behind

Thursday, December 9, 2010

Creating and merging two Images in C#

//Creating new Image
var bitmap1 = new Bitmap(1, 1);
var font = new Font("Arial", 25);
Graphics graphics = Graphics.FromImage(bitmap1);
int width1 = (int)graphics.MeasureString("hello world this is custome image", font).Width;
int height1 = (int)graphics.MeasureString("hello world this is custome image", font).Height;
bitmap1 = new Bitmap(bitmap1, new Size(width1, height1));
graphics = Graphics.FromImage(bitmap1);
graphics.Clear(Color.Gray);
graphics.DrawString("hello world this is custome image", font, new SolidBrush(Color.DarkGray), 0, 0);
graphics.Flush();

//accessing existing Image
var fileStream = new FileStream(Server.MapPath("//images//sky.jpg"), FileMode.Open);
var bytes1 = new byte[fileStream.Length];
fileStream.Read(bytes1, 0, bytes1.Length);
fileStream.Close();
var bitmap3 = new Bitmap(new MemoryStream(bytes1));

int width = bitmap3.Width;
int height = bitmap3.Height + height1;
var finalImage = new Bitmap(width, height);

//merging two images
//get a graphics object from the image so we can draw on it

var images = new List{bitmap3,bitmap1};
using (graphics = Graphics.FromImage(finalImage))
{
//set background color
graphics.Clear(Color.Transparent);

//go through each image and draw it on the final image
int offset = 0;
foreach (Bitmap image in images)
{
graphics.DrawImage(image,
new Rectangle(0, offset, image.Width, image.Height));
offset += image.Height;
}
}

// save on memory
var memoryStream = new MemoryStream();
finalImage.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] bytes = memoryStream.ToArray();

// throwing on web
HttpContext.Current.Response.ContentType = "image/jpeg";
HttpContext.Current.Response.Expires = 0;
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.BinaryWrite(bytes);
HttpContext.Current.Response.End();

Wednesday, December 8, 2010

Rotate any control in silverlight

Rotate any control in silverlight

var messageTextBlock = new TextBlock
{
Text = "Messages",
Margin = new Thickness(5,20,0,0),
//FontWeight = FontWeights.Bold,
Foreground = new SolidColorBrush(Colors.White),
VerticalAlignment = VerticalAlignment.Top,
Width = 70,
Height=20,
TextWrapping = TextWrapping.Wrap,
};
RotateTransform r = new RotateTransform();
messageTextBlock.RenderTransform = r;
r.CenterX = 0;
r.CenterY = 0;
r.Angle = 90;