Monday, June 30, 2014

How to Implement Timer for Windows 8.1 Store App in C#

Will this do the trick?



DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(10);
timer.Tick += timer_Ticker;
timer.Start();

private void timer_Ticker(object sender, EventArgs e)
{
// Do stuff
}


How to Implement Timer for Windows 8.1 Store App in C#

Thank you OlofPetterson It Solved my issue exactly.

RealProxy and Abstract Type

Hi,


You can't use RealProxy directly anyway, becuase its an abstract class. In your implementation of the concrete sub-class, you can introduce the MarshalByRefObject. The example code on the MSDN page shows how to do this (http://ift.tt/V2lo9R)


Regards,

Nick.


Need help in UPDATE data in SQL Query

Hi all,


I am trying to update data in the sql table as per below screenshot but couldn't able to do it. Can anyone help to update the data as I mention in screenshot.Appreciate you help.Thanks.


Yellow highlighted columns are source


Green highlighted columns are target



Colored data should be update as per source data in sql table.Data is not static as it might have more rows to update and query should be bit dynamic.




Maruthi...



Need help in UPDATE data in SQL Query

Is there a timestamp column which is used to order the rows in the display? If yes, that can be used to fill the empty cells.


UPDATE blog: http://ift.tt/1r45AAn




Kalman Toth Database & OLAP Architect SQL Server 2014 Design & Programming

New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012















Need help in UPDATE data in SQL Query

Hi Kalman,


yes I do have a timestamp column...But how can I do that?




Maruthi...


Need help in UPDATE data in SQL Query


Hi Kalman,


yes I do have a timestamp column...But how can I do that?




Maruthi...




UPDATE T SET WeekName = ISNULL(WeekName , (SELECT TOP 1 WeekName FROM YrTable WHERE timestamp < T.TimeStamp AND WeekName IS NOT NULL ORDER BY TimeStamp DESC))

FROM YrTable T







Thanks and regards, Rishabh K


Need help in UPDATE data in SQL Query

Please share the problem you are sharing to do it.


Also do you have any unique column in this case to just join and try that update statement.




Santosh Singh


Need help in UPDATE data in SQL Query

You have already asked this question once. You did not get any good answers, because you the information you gave was insufficient. And I'm afraid that the information is still in sufficient.


Or more exactly, from the example you have given, the answer is: can't be done. And the reason it can't be done, is as I explained in response to you first thread: there is no information in the data to from which we can deduce that Clorox Company should be under "Week 1-1,K.B,F". The fact that rows are listed in a certain order in the screenshoot is of no importance, because a table is an unordered object.


But you said in another post that you have a timestamp column. Maybe that column is usable - maybe it is not. But at least it is a key that you have more columns that the ones you show.


The best way to get help with this type of problems is to post:


1) CREATE TABLE statement for your table(s).

2) INSERT statements with sample data.

3) The desired result given the sample.

4) A short description of the actual buisness problem you are trying to solve.

5) Which version of SQL Server you are using.


This makes it easy to copy and paste into a query window to develop a tested solution. Screenshots with an insufficient amount of data is not going to help you very much.





Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Need help in UPDATE data in SQL Query


CREATE TABLE test (id int identity(1,1), weeknum INT,ord int,dt1 datetime, wd int)

INSERT INTO test VALUES (101,'1','2011-12-20','484')
INSERT INTO test VALUES (null,'2','2011-02-12','444')
INSERT INTO test VALUES (null,'3','2011-02-12','444')
INSERT INTO test VALUES (null,'4','2011-02-14',NULL)
INSERT INTO test VALUES (102,'1','2013-05-27','544')
INSERT INTO test VALUES (null,'2','2013-06-02','544')
INSERT INTO test VALUES (null,'3','2013-06-03',NULL)
INSERT INTO test VALUES (null,'4','2013-06-10',NULL)
INSERT INTO test VALUES (103,'5','2013-07-08',NULL)
INSERT INTO test VALUES (null,'6','2013-07-08','690')
INSERT INTO test VALUES (null,'7','2013-07-10','690')

;with mycte as
(
SELECT id,weeknum,dt1, row_number()over(order by id DESC) rn

FROM test A)

SELECT m.id,d.weeknum , m.dt1 FROM mycte m
OUTER APPLY (SELECT TOP 1 weeknum FROM mycte
WHERE rn>= m.rn AND weeknum IS NOT NULL
ORDER BY rn ) d (weeknum )

Order by id

drop table test



foreign key script question

You can try the below link


http://ift.tt/V2lduW


--Prashanth


foreign key script question

try below link


http://ift.tt/V2lduW


http://ift.tt/1vnP2RS


Why doesn't this conversion work?

I've created a RichTextBox dynamically in a method called newTab(), and assigned its .KeyDown event an eventhandler. In this event handler, this code does not work:



(RichTextBox)tabControl1.SelectedTab.Controls[0].AppendText(tabSpace)



Visual Studio says, "Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement"


Why is this? I'm pretty sure I got syntax messed up here, but this has worked before...I think.


Thanks for the help in advance!






“It is not that I'm so smart. But I stay with the questions much longer.” ― Albert Einstein


Why doesn't this conversion work?

Try this:



((RichTextBox)tabControl1.SelectedTab.Controls[0]).AppendText(tabSpace)


Why doesn't this conversion work?

Safe way to handle this is


RichTextBox rtbControl = tabControl1.SelectedTab.Controls[0] as RichTextBox

if ( rtbControl != null )
{
rtbControl.AppendText(tabSpace);
}



If this helps, mark it as an answer or vote it.

Why doesn't this conversion work?

Safe way to handle this is


RichTextBox rtbControl = tabControl1.SelectedTab.Controls[0] as RichTextBox

if ( rtbControl != null )
{
rtbControl.AppendText(tabSpace);
}



If this helps, mark it as an answer or vote it.

It’s not safe enought . What if SelectedTab is null or Controls is empty?



I am new to Microsoft.Office.Interop.Excel Marshal.ReleaseComObject

Hello,


Here is a very simple example that opens an Excel file, gets all sheet names, writes data to a cell, saves the file and finally releases all objects. Again this is a simple example to keep things easy to understand.



/// <summary>
/// The code accepts an Excel file to open, iterates thru the
/// WorkSheets collection checking the name passed in parameter 2
/// to see if it matches and if so sets a boolean so after the for-next
/// we can know if the sheet is there and safe to work on.
/// </summary>
/// <param name="FileName"></param>
/// <param name="SheetName"></param>
public void OpenExcel(string FileName, string SheetName)
{
List<string> SheetNames = new List<string>();

bool Proceed = false;
Excel.Application xlApp = null;
Excel.Workbooks xlWorkBooks = null;
Excel.Workbook xlWorkBook = null;
Excel.Worksheet xlWorkSheet = null;
Excel.Sheets xlWorkSheets = null;

xlApp = new Excel.Application();
xlApp.DisplayAlerts = false;
xlWorkBooks = xlApp.Workbooks;
xlWorkBook = xlWorkBooks.Open(FileName);

xlApp.Visible = false;
xlWorkSheets = xlWorkBook.Sheets;

for (int x = 1; x <= xlWorkSheets.Count; x++)
{
xlWorkSheet = (Excel.Worksheet)xlWorkSheets[x];

SheetNames.Add(xlWorkSheet.Name);

if (xlWorkSheet.Name == SheetName)
{
Proceed = true;
Excel.Range xlRange1 = null;
xlRange1 = xlWorkSheet.Range["A1"];
xlRange1.Value = "Hello";
Marshal.FinalReleaseComObject(xlRange1);
xlRange1 = null;
xlWorkSheet.SaveAs(FileName);
break;
}

System.Runtime.InteropServices.Marshal.FinalReleaseComObject(xlWorkSheet);
xlWorkSheet = null;
}

xlWorkBook.Close();
xlApp.Quit();

ReleaseComObject(xlWorkSheets);
ReleaseComObject(xlWorkSheet);
ReleaseComObject(xlWorkBook);
ReleaseComObject(xlWorkBooks);
ReleaseComObject(xlApp);

if (Proceed)
{
MessageBox.Show("Found sheet, do your work here.");
}
else
{
MessageBox.Show("Sheet not located");
}

MessageBox.Show("Sheets available \n" + String.Join("\n", SheetNames.ToArray()));
}

private void ReleaseComObject(object obj)
{
try
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
obj = null;
}
catch (Exception ex)
{
obj = null;
}
}

One last thing, see the Two Dot Rule.




Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.


Parameter-less query if fast, but slow in procedure

Do you have many set options in your stored procedure? Are you facing this issue in only one environment or is it reproducible ?


Have you tried running the stored procedure with recompile clause , so that it uses a new plan for the stored procedure? May be the plan which is in the cache might not be the best plan for this stored procedure.


Do you know the waittype of the stored procedure execution?


Could you see if the plans for the query and stored procedure has a major difference?




Regards, Ashwin Menon My Blog - http:\\sqllearnings.com


Does Microsoft have similar solution as XSLT?

Is this question specific to Windows Store apps or is it a general Windows question?


Matt Small - Microsoft Escalation Engineer - Forum Moderator

If my reply answers your question, please mark this post as answered.



NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.


Matrix Report does not show all data

Hi BananaBrains,


Does it show records properly in the Query Builder when creating dataset? It supposed to return same records as we did in SQL Server Management Studio.


Best Regards,

Simon Hou


Matrix Report does not show all data

Hi Simon,


No it does not show all of the information in Query Builder when I press the red !. it shoes about 50%.


thanks for your help.


Allana


Matrix Report does not show all data

Hi BananaBrains,


Did it return all records properly in SQL Server Management Studio? If so, please try to restart your Report Server in Reporting Services Configuration.


Best Regards,

Simon Hou


C# load images or data into ram

I'm trying to access the physical ram of a pc. I need to load an image into the ram and retrieve it. This is merely a test application for stress testing physical memory. How would I access the ram directly so to speak where I could then pass an image directly into it ?


Just looking for some idea's



C# load images or data into ram

With Image.FromFile you can load an image into RAM. With ‘var [] bytes = new byte[1000000]’ you can get some other RAM for your tests. Memory-consumption experiments can be also done with MemoryStream.


Creating SOAP Web Service Step by Step

Dear all



i want to Create a SOAP Web Service using C#, VS2010.



i want to give it the XML as attached Request.xml.

i want to the result to be as attached Response.xml.



i want a walk through how can i accomplish this.


Check this link for the Attachments:


http://ift.tt/1pE7MPJ


please i need help.



thanks,




Ramzy N.Ebeid


Parameter-less query if fast, but slow in procedure

Hello everyone,


I have the following query that returns me around 500,000 rows. It runs in around 1 minute and 30-40 seconds when runs as query, but as a procedure, it goes up to 8 minutes. What may I be missing? I received it for maintenance but can't find what the bottleneck is:



SELECT
AL.CD_ALMOXARIFADO,
AL.DC_ALMOXARIFADO,
UN.CD_SUPRI,
UN.TXT_DCR_UNID_SAUD,
MT.COD_MATE_SAUDE,
MT.DESCRICAO,
MT.UNIDADE_MEDIDA,
CAST(ISNULL(EL.QT_CMM, 0) AS DECIMAL(12,2)) AS QT_CMM_INFORMADO,
CAST(ISNULL(CM.QT_CMM_CALCULADO, 0) AS DECIMAL(12,2)) AS QT_CMM_CALCULADO,
ISNULL(EL.QT_ESTOQUE, 0) AS QT_ESTOQUE
FROM
ALMOXARIFADO AL (NOLOCK)
INNER JOIN ESTOQUE_LOCAL EL (NOLOCK)
ON AL.CD_ALMOXARIFADO = EL.CD_ALMOXARIFADO
INNER JOIN T9216_UNIDAD_SAUDE UN (NOLOCK)
ON EL.COD_UNID_SAUD = UN.COD_UNID_SAUD
INNER JOIN T9115_MAT_SERV_SAD MT (NOLOCK)
ON EL.COD_MATE_SAUDE = MT.COD_MATE_SAUDE
INNER JOIN PARAMETRO_ESTOQUE_UNIDADE PU (NOLOCK)
ON EL.COD_UNID_SAUD = PU.COD_UNID_SAUD
INNER JOIN
(
SELECT
DISTINCT ku.cod_unid_saud, ki.cod_mate_saude
FROM
kit kt
INNER JOIN
kit_item ki
ON kt.ci_kit = ki.ci_kit
INNER JOIN
kit_x_unidade ku
ON kt.ci_kit = ku.ci_kit
INNER JOIN
T9216_unidad_saude u on u.cod_unid_saud=ku.cod_unid_saud
WHERE
kt.in_status = 'A' AND
ki.in_status = 'A'
AND DT_FIM_UNID_SAUD IS NULL
) AS MU
ON EL.COD_MATE_SAUDE = MU.COD_MATE_SAUDE AND
EL.COD_UNID_SAUD = MU.COD_UNID_SAUD
LEFT JOIN
(
SELECT
mp.cod_unid_saud,
mi.cd_almoxarifado,
mi.cod_mate_saude,
(SUM(mi.qt_movimento) / 90) * 30 AS QT_CMM_CALCULADO
FROM
movimento_produto mp (nolock)
INNER JOIN
movimento_item mi (nolock)
ON mp.id_movimento = mi.id_movimento
WHERE
mp.cd_tipo_movto IN ('S', 'U', 'X', 'D') AND
mp.dt_movimento BETWEEN DATEADD(d, -90, GETDATE()) AND GETDATE() AND
(mi.in_estorno IS NULL OR mi.in_estorno = 'N')
GROUP BY
mp.cod_unid_saud,
mi.cd_almoxarifado,
mi.cod_mate_saude
) AS CM
ON EL.COD_UNID_SAUD = CM.COD_UNID_SAUD AND
EL.CD_ALMOXARIFADO = CM.CD_ALMOXARIFADO AND
EL.COD_MATE_SAUDE = CM.COD_MATE_SAUDE
WHERE
(EL.IN_BLOQUEIO = 'N' OR EL.IN_BLOQUEIO IS NULL) AND
((UN.CD_SUPRI IS NOT NULL OR UN.CD_SUPRI <> '') AND CD_SUPRI NOT LIKE '1810%') AND
AL.IN_STATUS = '0' AND
MT.TP_ORIGEM_ABASTECIMENTO = 'A' AND
MT.IN_REQUISICAO_ABASTECIMENTO = 'S' AND
PU.IN_REQUISICAO_ABASTECIMENTO = 'S' AND
PU.IN_ATENDIMENTO = 'S'
ORDER BY
UN.COD_UNID_SAUD,
AL.CD_ALMOXARIFADO,
MT.COD_MATE_SAUDE

If anyone has any other hints/tips on any optimization I may be missing, I appreciate.


Thanks in advance,


Marcelo




Marcelo

http://ift.tt/1lrQ75l - Price Comparison. Need the lowest price? We find it for you.


How to change the icon size of an AppBarButton?

AppBarButtons are fixed in their graphical properties.


Matt Small - Microsoft Escalation Engineer - Forum Moderator

If my reply answers your question, please mark this post as answered.



NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.


Stacking controls wider than a page

Another important thing to note, is that if you are using a Basic app page, with a title and back arrow at the top left of the page, you should enclose the contents of your page with a grid, contained within a ScrollViewer control, as shown in the following example:



<Page.Resources>

<!-- TODO: Delete this line if the key AppName is declared in App.xaml -->
<x:String x:Key="AppName">Addresses</x:String>
</Page.Resources>
<ScrollViewer HorizontalScrollMode="Auto" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" >
<Grid>

<Grid Style="{StaticResource LayoutRootStyle}">


<Grid.RowDefinitions>
<RowDefinition Height="140"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<!-- Back button and page title -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
<TextBlock x:Name="pageTitle" Grid.Column="1" Text="{StaticResource AppName}" Style="{StaticResource PageHeaderTextStyle}" FontSize="48"/>
</Grid>

<StackPanel Margin="203,310,-83,0" Orientation="Horizontal" VerticalAlignment="Top" Grid.Row="1">
<TextBox HorizontalAlignment="Left" TextWrapping="Wrap" Text="TextBox 0 9 0 888 9" VerticalAlignment="Top" Width="772" Canvas.Left="10" Canvas.Top="29"/>
<TextBox HorizontalAlignment="Left" TextWrapping="Wrap" Text="TextBox 0 9 0 888 9" VerticalAlignment="Top" Width="772" Canvas.Left="10" Canvas.Top="29"/>
<TextBox HorizontalAlignment="Left" TextWrapping="Wrap" Text="TextBox 0 9 0 888 9" VerticalAlignment="Top" Width="772" Canvas.Left="10" Canvas.Top="29"/>
</StackPanel>

</Grid>
</Grid>
</ScrollViewer>

You can then place your StackPanel control, directly within the second level grid control. This will allow the controls within your StackPanel control, to scroll beyond the edge of your app page.


serial number for matrix columns in ssrs

Add a row above current data row inside group and use expression as below



=RowNumber(Nothing)





Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c



Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource.

Does this work?



protected override void CreateChildControls()
{
SPSite site = SPContext.Current.Site;
SPWeb web = SPContext.Current.Web;
SPQuery query = new SPQuery();
SPList list1 = web.Lists.TryGetList("Vendor");
if list1 != null)
{
DataTable dtvendor = new DataTable();
dtvendor = list1.GetItems(query).GetDataTable();
drpList.DataSource = dtvendor;
drpList.DataTextField = "Company";
drpList.DataValueField = "ID";
drpList.DataBind();
Controls.Add(drpList);
drpList.SelectedIndexChanged += new EventHandler(this.ddlAllLists_SelectedIndexChanged);
}
}



Good Luck!


Alex


passing 'date' data from external app to SP2010 date field

Hi, I am using SP2010 to store scanned PDF documents. The docs are scanned using Nuance ScanFlowStore, using a cover page with barcodes to route the docs to a document folder. I am trying to pass 'date' data format is plain numeric, NOT a true date value, but set as MMDDYYYY). The date data is input by my users and gets embedded in a barcode. I have 2 fields/columns in SP2010, one defined as datetime, the other as a single line of text. The text field gets updated with the 'date' data but not the datetime field. I need to have the date field updated so that SP2010 users can sort on the date column. I tried a calculated field using the text field as input, using Text(Date,"mm-dd-yyyy"), but the calculated field isn't sorting correctly either.


What should the date format be to update SP correctly?


Any suggestions would be greatly appreciated !!!!


how to create control array of winsock control control/controls in c# windows forms

Dear Mr.Muthukrishnan Ramasamy


Thank you for replying to my post/query. After reading your reply. I have changed my c# code. Given below is my c# code:



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Diagnostics;
namespace DRRS_Socket_Application
{
public partial class Form1 : Form
{
private AxMSWinsockLib.AxWinsock axWinsock1;
private AxMSWinsockLib.AxWinsock[] sckClient = new AxMSWinsockLib.AxWinsock[20];
public Form1()
{
InitializeComponent();
sck = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
sck.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
}
private void Form1_Load(object sender, EventArgs e)
{
int x;
for (x = 0; x < 20; x++)
{
sckClient[x]=new AxMSWinsockLib.AxWinsock();
((System.ComponentModel.ISupportInitialize)(this.axWinsock1)).BeginInit();
sckClient[x].Enabled = true;
axWinsock1.EndInit();
StartListen();
}
}
private void StartListen()
{
sckServer.Close();
sckServer.LocalPort = 25000;
sckServer.Listen();
}

Is this enough for creating control array of winsock control in c# windows forms? Or should i need to create Active X Control((Winsock control) from scratch in designer.cs in c# windows forms? Reply please Sir? I am waiting for your reply!?



vishal


how to create control array of winsock control control/controls in c# windows forms

You are missing the last point.


Add an Invisible Panel (like Panel1)


add the WinSock controls to that panel


THIS SHOULD BE AFTER EndInit




Muthukrishnan Ramasamy

net4.rmkrishnan.net

Use only what you need, Reduce global warming


how to create control array of winsock control control/controls in c# windows forms

Dear Mr.Muthukrishnan Ramasamy


Are you telling that i should add a panel control(named:Panel1) to my Form1(name of my form in c# windows forms) at design time with all other controls inside it?


Given below is c# code of Form1.Designer.cs:



namespace DRRS_Socket_Application
{
partial class Form1
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.listBox1 = new System.Windows.Forms.ListBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.button3 = new System.Windows.Forms.Button();
this.Winsock1 = new AxMSWinsockLib.AxWinsock();
this.sckServer = new AxMSWinsockLib.AxWinsock();
this.axWinsock1 = new AxMSWinsockLib.AxWinsock();
((System.ComponentModel.ISupportInitialize)(this.Winsock1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.sckServer)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.axWinsock1)).BeginInit();
this.SuspendLayout();
// listBox1
//
this.listBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 18;
this.listBox1.Location = new System.Drawing.Point(22, 23);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(301, 382);
this.listBox1.TabIndex = 1;
this.listBox1.Click += new System.EventHandler(this.listBox1_Click);
this.listBox1.DoubleClick += new System.EventHandler(this.listBox1_DoubleClick);
//
// button1
//
this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button1.Location = new System.Drawing.Point(345, 61);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(151, 43);
this.button1.TabIndex = 2;
this.button1.Text = "Get IP Address";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button2.Location = new System.Drawing.Point(345, 110);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(151, 48);
this.button2.TabIndex = 3;
this.button2.Text = "Start Listen";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// textBox1
//
this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textBox1.Location = new System.Drawing.Point(22, 427);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(301, 43);
this.textBox1.TabIndex = 7;
this.textBox1.Text = "localhost";
//
// textBox2
//
this.textBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textBox2.Location = new System.Drawing.Point(345, 427);
this.textBox2.Multiline = true;
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(151, 43);
this.textBox2.TabIndex = 8;
this.textBox2.Text = "1234";
//
// textBox3
//
this.textBox3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textBox3.Location = new System.Drawing.Point(22, 476);
this.textBox3.Multiline = true;
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(474, 145);
this.textBox3.TabIndex = 9;
this.textBox3.Text = "Message";
//
// button3
//
this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button3.Location = new System.Drawing.Point(432, 628);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(94, 43);
this.button3.TabIndex = 10;
this.button3.Text = "Send";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// Winsock1
//
this.Winsock1.Enabled = true;
this.Winsock1.Location = new System.Drawing.Point(390, 226);
this.Winsock1.Name = "Winsock1";
this.Winsock1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("Winsock1.OcxState")));
this.Winsock1.Size = new System.Drawing.Size(28, 28);
this.Winsock1.TabIndex = 11;
this.Winsock1.Error += new AxMSWinsockLib.DMSWinsockControlEvents_ErrorEventHandler(this.Winsock1_Error_1);
this.Winsock1.DataArrival += new AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEventHandler(this.Winsock1_DataArrival_1);
this.Winsock1.ConnectEvent += new System.EventHandler(this.Winsock1_ConnectEvent_1);
//
// sckServer
//
this.sckServer.Enabled = true;
this.sckServer.Location = new System.Drawing.Point(366, 277);
this.sckServer.Name = "sckServer";
this.sckServer.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("sckServer.OcxState")));
this.sckServer.Size = new System.Drawing.Size(28, 28);
this.sckServer.TabIndex = 12;
this.sckServer.ConnectEvent += new System.EventHandler(this.sckServer_ConnectEvent);
this.sckServer.ConnectionRequest += new AxMSWinsockLib.DMSWinsockControlEvents_ConnectionRequestEventHandler(this.sckServer_ConnectionRequest_1);
//
// axWinsock1
//
this.axWinsock1.Enabled = true;
this.axWinsock1.Location = new System.Drawing.Point(400, 277);
this.axWinsock1.Name = "axWinsock1";
this.axWinsock1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axWinsock1.OcxState")));
this.axWinsock1.Size = new System.Drawing.Size(28, 28);
this.axWinsock1.TabIndex = 13;
this.axWinsock1.Error += new AxMSWinsockLib.DMSWinsockControlEvents_ErrorEventHandler(this.axWinsock1_Error);
this.axWinsock1.DataArrival += new AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEventHandler(this.axWinsock1_DataArrival);
this.axWinsock1.ConnectEvent += new System.EventHandler(this.axWinsock1_ConnectEvent);
this.axWinsock1.CloseEvent += new System.EventHandler(this.axWinsock1_CloseEvent);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(637, 729);
this.Controls.Add(this.axWinsock1);
this.Controls.Add(this.sckServer);
this.Controls.Add(this.Winsock1);
this.Controls.Add(this.button3);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.listBox1);
this.Name = "Form1";
this.Text = "Server Listening";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.Winsock1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.sckServer)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.axWinsock1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion

private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;

private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Button button3;
private AxMSWinsockLib.AxWinsock Winsock1;
private AxMSWinsockLib.AxWinsock sckServer;
private AxMSWinsockLib.AxWinsock sckClient1;
private AxMSWinsockLib.AxWinsock axWinsock1;
}
}

Sorry for my long code of my form named: Form1.Designer.cs


I just thought that this might provide clear idea of how to create control array of winsock control in c# windows forms.


If not can you provide me a sample of adding invisible panel to my Form1 and adding Winsock controls to that panel which should be be AFTER EndInit.? Reply please?! I am waiting for your reply Sir!




vishal


sql query

Try



select 10 Projectid , 1 status into #temp1 union all
select 10 , 0 union all
select 11 ,0 union all
select 12 , 1 union all
select 13 ,0

select isnull(a.Projectid,b.Projectid), case
when a.status =0 and b.status =1 then 2
when a.status =0 and b.status is null then 1
when b.status =1 and a.status is null then 0
else null end
from
(select * from #temp1 where status = 0)a
full outer join
(select * from #temp1 where status = 1)b
on a.Projectid=b.Projectid
order by 1

Thanks


Saravana Kumar C


Provide access to Custom Control Method

Thanks for your response.


What I am trying to do is expose the event handler not listener. In case of your sample, it should be something like this:


In UserControl.Xaml



<UserControl
x:Class="Usercontrolevent.MyUserControl1"
xmlns="http://ift.tt/w9rHWX;
xmlns:x="http://ift.tt/zZkFEV;
xmlns:local="using:Usercontrolevent"
xmlns:d="http://ift.tt/PuXO1J;
xmlns:mc="http://ift.tt/R4RR6u;
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400" x:Name="mycontrol">

<Grid>
<ListView x:Name="listView" ItemTemplate="{Binding ItemTemplate}" ItemsSource="{Binding ItemsSource}"></ListView>
</Grid>
</UserControl>



In UserControls.cs



public sealed partial class MyUserControl1 : UserControl
{
public MyUserControl1()
{
this.InitializeComponent();
this.listView.DataContext=this;
}
public static readonly DependencyProperty ItemTemplateProperty =
DependencyProperty.Register(
"ItemTemplate",
typeof(String),
typeof(MyUserControl1), null
);
public DataTemplate ItemTemplate
{
get { return (DataTemplate)GetValue(ItemTemplateProperty); }
set { SetValue(ItemTemplateProperty, (DataTemplate)value); }
}
public static readonly DependencyProperty ItemsSourceProperty =
DependencyProperty.Register(
"ItemsSource ",
typeof(object),
typeof(MyUserControl1), null
);
public object ItemsSource
{
get { return (object)GetValue(ItemTemplateProperty); }
set { SetValue(ItemTemplateProperty, (object)value); }
}

public void HandlerIWantToExpose(object sender, RoutedEventArgs e)
{
//Do Something
}

}



In MainPage.Xaml





<Page.Resources>

<CollectionViewSource x:Name="cvs1" />
<DataTemplate x:Key="AllSubjectsHeaderTemplate">
<Border BorderBrush="#FF677E7B"
BorderThickness="0,0,0,1"
Background="#FF534C4C">
<StackPanel Orientation="Horizontal">
<CheckBox x:Name="checkBox"
HorizontalAlignment="Left"
Margin="10"
VerticalAlignment="Top"
IsChecked="{Binding IsChecked}"
Width="27" Checked="[HandlerExposedByMyUserControl1]" />
</StackPanel>
</Border>
</DataTemplate>
</Page.Resources>

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<local:MyUserControl1 ItemTemplate="{StaticResource AllSubjectsHeaderTemplate}" ItemsSource="{StaticResource cvs1}"></local:MyUserControl1>
</Grid>



MainPage.cs


public MainPage()
{
this.InitializeComponent();

ObservableCollection<Test> test = new ObservableCollection<Test>();
test.Add(new Test { IsChecked = true });
test.Add(new Test { IsChecked = false });
test.Add(new Test { IsChecked = true });
test.Add(new Test { IsChecked = false });
cvs1.Source = test;


}
}
public class Test
{
public bool IsChecked { get; set; }
}


Hiding Calloutlines in smart labels in ssrs

Hi Nagaraju,


According to your description, you get some small line under your values when these values are very close in your bar chart. Right?


In Reporting Services, even having same values and label displayed, we didn't find any lines displayed in bar chart when we tested in our environment. Could you please post some detail information and screenshots about your report if possible. This may help us reproduce your issue in our local lab. Thank You.


Reference:

Bar Charts (Report Builder and SSRS)


Best Regards,

Simon Hou


Hiding Calloutlines in smart labels in ssrs

Hi Simon,


Here i am uploading an image, with this you can understand the scenario.



i want to hide the above small lines in the bars.


Thanks for your reply.


Regards,


Can a TextBlock in a Flyout have wrapped text?

The TextBlock in the following code does not wrap.



<AppBarButton x:Name="abbFooHelp" Icon="Help" IsCompact="True" VerticalAlignment="Center" HorizontalAlignment="Center">
<AppBarButton.Flyout>
<Flyout>
<TextBlock TextWrapping="Wrap">This is a very looooooooooooooooooooog text. This is a very looooooooooooooooooooog text.</TextBlock>
</Flyout>
</AppBarButton.Flyout>
</AppBarButton>



Could any one offer a tip?




Hong


Can a TextBlock in a Flyout have wrapped text?

change it to:



<Flyout>
<Grid Width="100">
<TextBlock TextWrapping="Wrap">This is a very looooooooooooooooooooog text. This is a very looooooooooooooooooooog text.</TextBlock>
</Grid>
</Flyout>





Microsoft Certified Solutions Developer - Windows Store Apps Using C#


how to create control array of winsock control control/controls in c# windows forms

Dear Kevininstructor the Microsoft community contributor,Moderator


My name is Vishal. Where have you Sir moved my question that i posted in Msdn(Windows data binding forum) forums on Friday around 11-11:30 am to which forum or to which category of Msdn forum have you moved my question for better support.? Reply please?! I am asking you this question to you Sir because i want to know where my question is and if i am lucky i want to see some replies(good/bad) associated with question. Kindly tell me where have you Sir moved my question to ? Reply please?!


Regards


Vishal.S




vishal


how to create control array of winsock control control/controls in c# windows forms

Control Arrays are no longer supported in .Net


Creating an Active X control at run time needs some workaround.


I would recommend using System.Net.Sockets




Muthukrishnan Ramasamy

net4.rmkrishnan.net

Use only what you need, Reduce global warming


how to create control array of winsock control control/controls in c# windows forms

In your Form_Load, you created AxWinSock object.


After that you called BeginInit


What you are missing is, EndInit


Just Copy the BeginInit line and change "Begin" to "End" :)


Another important missing peace is, Active controls will work only if you add it to a Form or its Child (like Panel)




Muthukrishnan Ramasamy

net4.rmkrishnan.net

Use only what you need, Reduce global warming


Formatting SQL table data by creating a new column

Hi All,


I am not able to figure it out how I can solve issue by writing sql query.In below screen shot yellow columns are the source and green colour are output columns. How can I write a sql query to solve the issue? Appreciate any help from any one :)




Maruthi...


Formatting SQL table data by creating a new column

The answer is that with the given source data, it is not possible produce the source. The reason for this is that a table is an unordered object, so there is no such thing as a "first row".


If there is a hidden column which defines the order in the source, it is logically possible, although still a little tricky. I suspect though that what you call source columns are not the actual source, but they are in their turn derived from another source, and maybe we should go back one step to make the problem simpler.





Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Formatting SQL table data by creating a new column

Hi Erland,


Thanks for the reply. Is this can be solved by using SSIS?




Maruthi...


Formatting SQL table data by creating a new column

SSIS? You cannot accuse me for knowing too much about SSIS, but you present some data, and you want a query to produce a certain result. And then you start to talk about SSIS? I don't see where SSIS would fit in. It seems that there is some details about the context of your problem you have not told us about.





Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Formatting SQL table data by creating a new column

Issue is resolve by following link


http://ift.tt/1md0WhM




Maruthi...


Question of general direction...

Hi,


You work with windows store app, so I moved this thread to Building Windows Store apps with C# or VB forum for better support.


Thanks,




We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

Click HERE to participate the survey.


Faulting module name: combase.dll

I recently found out that problem still occur. This time I've saved dumpfiles. May I continue on this thread? If yes, where do I email the location to the dump files?


Sunday, June 29, 2014

Unpivot, Pivot without Aggregation



Unpivot, Pivot without Aggregation

Few other methods


Using UNPIVOT



declare @t table
(
Eventname varchar(100),
Eventmanager varchar(100),
Staff varchar(100),
Volunteer varchar(100)
)

INSERT @t
VALUES ('Fundrive','Mr.Z','Xyz1','Abc1'),
('Fundrive','Mr.Z','Xyz2','Abc2'),
('Fundrive','Mr.Z','Xyz3','Abc3')

SELECT DISTINCT JobDescription,Name
FROM @t t
UNPIVOT (Name FOR JobDescription IN ([Eventmanager],[Staff],[Volunteer]))u
ORDER BY JobDescription,Name



Using VALUES clause



SELECT DISTINCT JobDescription,Name
FROM @t t
CROSS APPLY (VALUES('Eventmanager',[Eventmanager]),('Staff',[Staff]),('Volunteer',[Volunteer]))u(JobDescription,Name)







Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


Unpivot, Pivot without Aggregation

Thank you.


I helps but I have seems I need little different than I thought.



Really Appreciate your help.


Unpivot, Pivot without Aggregation


Thank you.


I helps but I have seems I need little different than I thought.



Really Appreciate your help.



How did you get A2,A3 for column2 and column3? as per your sample data it should be A1,A2


Assuming its a typo what you need is this



declare @t table
(
column1 varchar(2),
column2 varchar(2),
column3 varchar(2),
column4 varchar(2),
column5 varchar(2),
column6 varchar(2),
column7 varchar(2),
column8 varchar(2)
)

insert @t
values ('A1','A2','A3','A4','A5','A6','A7','A8')


SELECT Role,Name
FROM @t
UNPIVOT (Name FOR Role IN
(
[Column1],
[Column2],
[Column3],
[Column4],
[Column5],
[Column6],
[Column7],
[Column8]
))u
ORDER BY Role



replace @t with your actual tablename in your case.






Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


Unpivot, Pivot without Aggregation

Thank you for answer.


This Solved my immediate problem from one table when I insert that data but the question comes up now is when I get data from joining 4 table without me inserting it in one table.



update one table from another when the column names match

While Dan's solution is my preference, it also works if you put the table variable in brackets:


update @people set prims=(select prims from PrimOwners where PrimOwners.avatarkey=[@people].avatarkey)





Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Library placement when developing with sqlite

Hi Bonnie,



Thanks for the reply, it seems the interop dll's can not be added as a reference.

I'll hit the sqlite forums on this one as I am sure there will be an accepted best

practise they follow.



Thank you!


update one table from another when the column names match

One workaround is the UPDATE...FROM syntax:



update p
set prims=(select PrimOwners.prims from PrimOwners where PrimOwners.avatarkey=p.avatarkey)
FROM @people p;





Dan Guzman, SQL Server MVP, http://www.dbdelta.com


how to create sharePoint 2010 anonymous access team site

Hi All,


I have a "Team Site" with 8 Static pages and two list. Now my client wants this site to be publicly published with anonymous access to only 8 pages and two list form.


1) How to extend the existing team site to anonymous access.


2) Anonymous users should have access to only 8static Pages and two list/list forms.


3) Anonymous users should not access any other pages like _layouts/viewlsts.aspx or _layouts/settings.aspx.


Can some please guide me how can I get the above things done.




MercuryMan


how to create sharePoint 2010 anonymous access team site

Hi


1.Check this link


http://ift.tt/1x1poF1


2. work with permissions inheritance on each resource on your site


3. For this check this doc


http://ift.tt/1qoMlS1





Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.


Console Application doubt

I am creating a console application, with custom size and/or position.


When this application is double clicked in a File Explorer window, or instantiated through the command line, I want this console application window's top left corner be positioned at screen position (0,0).


How to do it?


Console Application doubt

Hello zyyqzyyra,


1. You can use the GetConsoleWindow() and SetWindowPos() APIs.


2. Here is a sample code for you to begin with :



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace CSConsoleApp01
{
class Program
{
const Int32 SW_MINIMIZE = 6;

const UInt32 SWP_NOSIZE = 0x0001;
const UInt32 SWP_NOMOVE = 0x0002;
const UInt32 SWP_NOZORDER = 0x0004;
const UInt32 SWP_NOREDRAW = 0x0008;
const UInt32 SWP_NOACTIVATE = 0x0010;
const UInt32 SWP_FRAMECHANGED = 0x0020; /* The frame changed: send WM_NCCALCSIZE */
const UInt32 SWP_SHOWWINDOW = 0x0040;
const UInt32 SWP_HIDEWINDOW = 0x0080;
const UInt32 SWP_NOCOPYBITS = 0x0100;
const UInt32 SWP_NOOWNERZORDER = 0x0200; /* Don't do owner Z ordering */
const UInt32 SWP_NOSENDCHANGING = 0x0400; /* Don't send WM_WINDOWPOSCHANGING */

const UInt32 SWP_DRAWFRAME = SWP_FRAMECHANGED;
const UInt32 SWP_NOREPOSITION = SWP_NOOWNERZORDER;

const Int32 HWND_TOP = 0;
const Int32 HWND_BOTTOM = 1;
const Int32 HWND_TOPMOST = -1;
const Int32 HWND_NOTOPMOST = -2;

[DllImport("Kernel32.dll", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
private static extern IntPtr GetConsoleWindow();

[DllImport("User32.dll", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool ShowWindow([In] IntPtr hWnd, [In] Int32 nCmdShow);

[DllImport("User32.dll", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetWindowPos
(
[In] IntPtr hWnd,
[In] IntPtr hWndInsertAfter,
[In] Int32 X,
[In] Int32 Y,
[In] Int32 cx,
[In] Int32 cy,
[In] UInt32 uFlags
);

private static void MinimizeConsoleWindow()
{
IntPtr hWndConsole = GetConsoleWindow();
ShowWindow(hWndConsole, SW_MINIMIZE);
}

private static void PositionWindow(Int32 X, Int32 Y, Int32 cx, Int32 cy)
{
IntPtr hWndConsole = GetConsoleWindow();
SetWindowPos(hWndConsole, (IntPtr)HWND_TOP, X, Y, cx, cy, SWP_SHOWWINDOW);
}

static void Main(string[] args)
{
PositionWindow(0, 0, 300, 300);
Console.ReadKey();
}
}
}

- Bio.



Please visit my blog : http://ift.tt/1r6KxsJ


I am new to Microsoft.Office.Interop.Excel Marshal.ReleaseComObject

Hi


I am new to Microsoft.Office.Interop.Excel


if I create following instance of types.


Workbooks books = Excel.WorkBooks;

Workbook book = books[1];

Sheets sheets = book.WorkSheet;

Worksheet ws = sheets[1];


how to release all objects?


Can I only use:


Marshal.ReleaseComObject(books);


Or


Marshal.ReleaseComObject(sheets);

Marshal.ReleaseComObject(books);


Sorting Attachment Lists

Hallo


Change the view of the list and edit the sort setting of the view. You can sort it by Created to make sure that the newest item is on top :)



Sorting Attachment Lists

Hi


Please check the similar post here


http://ift.tt/1qHEixA


http://ift.tt/1qHEixA


MAKE IP TO URL

how to make IP into URL...plz suggest


Performance problem to load data from sql server!

Hi


in my app, we have a report which get data from sql server proc. my problem is in database server, this proc take 2-3 seconds to load data from ssms but in my app (which exists on database server), it takes 20-30 seconds (or higher) to load and make cause TimeOut exception.


here is my code to run proc and get data from sql server :



public static DataTable GetDataByProcedure(string procName, Dictionary<string, object> parameters, string connectionString)
{
DataTable dtResult = new DataTable();
try
{
using (SqlConnection con = new SqlConnection(connectionString))
{
SqlCommand cmd = con.CreateCommand();
cmd.CommandText = procName;
cmd.CommandType = CommandType.StoredProcedure;

if (parameters != null)
{
foreach (string parameter in parameters.Keys)
{
cmd.Parameters.AddWithValue(parameter, parameters[parameter]);
}
}

if (con.State != ConnectionState.Open)
con.Open();

dtResult.Load(cmd.ExecuteReader());

if (con.State != ConnectionState.Closed)
con.Close();
}
}
catch { return dtResult; }
return dtResult;
}



however, the above code is really clear and straightforward, but I think there is a faster way to get data from sql server like ssms!!!


can anybody help me ?


thanks in advance




http://ift.tt/1bGq8Xs


Performance problem to load data from sql server!

I don't think you can improve that too much if you still want to use a datatable, because that is where your bottleneck is performancewise.


You are still doing the actual load of data as fast as in SSMS, however, when populating the datatable, you get a performancedrop in exchange for a quickly defined object structure to use later on.


You could of course improve it by skipping the datatable and instead load the resultset in custom objects. This is maybe not possible depending on the rest of your implementation. Another solution is to try to reduce the number of rows/columns you get back which is what I would opt for first and foremost.


Some links:


http://ift.tt/1lXrL9u


http://ift.tt/1nGi8ZD


Performance problem to load data from sql server!

Thanks for reply


but I don't have a lot of data! as I told in my first post, it takes only 2-3 seconds in ssms, but I don't know why this takes along time to complete within my app!!




http://ift.tt/1bGq8Xs


Performance problem to load data from sql server!

The suggestion to use the DataReader was only for testing purposes. David was saying that it should be quick to fetch the results reading from the DataReader in a loop. That will tell you whether or not it is as quick as executing in SSMS. If not, something else is going on (hence his suggestion to try using SQL Profiler).


I'm still curious as to how many rows you're returning ... 20-30 seconds to complete the query seems like an awfully lot of data being returned. How many rows are returned and do you really need them all?




~~Bonnie DeWitt [C# MVP]


http://ift.tt/1bPbIRj


Copy a table from Server to my local computer

Use the SSIS Import/Export Wizard:


http://ift.tt/1gluhCC




Kalman Toth Database & OLAP Architect SQL Server 2014 Design & Programming

New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012















Copy a table from Server to my local computer

Hi Erland,


Thanks a lot for your very instructive answers.


It has answered all my questions.


Best Regards


Leon Lai


What is the Equivalent of SCOPE_IDENTITY for SEQUENCE object?

The OUTPUT clause can be used. Is there any other choice? Thanks.



CREATE SEQUENCE dbo.NextCustomerID
as BIGINT
START WITH 1
INCREMENT BY 1;
GO

-- Get the next available ID
CREATE TABLE Customer(
CustomerID BIGINT DEFAULT (NEXT VALUE FOR dbo.NextCustomerID),
Name nvarchar(50) DEFAULT (SPACE(0)),
ModifiedDate datetime default (CURRENT_TIMESTAMP));
GO

SET NOCOUNT ON;

INSERT Customer DEFAULT VALUES;
GO 100

SELECT * FROM Customer;
GO
/*
CustomerID Name ModifiedDate
1 2014-06-29 11:53:51.317
2 2014-06-29 11:53:51.320
3 2014-06-29 11:53:51.320
4 2014-06-29 11:53:51.320
5 2014-06-29 11:53:51.320
6 2014-06-29 11:53:51.320
7 2014-06-29 11:53:51.320
...
*/





Kalman Toth Database & OLAP Architect SQL Server 2014 Design & Programming

New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012















Hiding Calloutlines in smart labels in ssrs

Hi Nagaraju,


According to your description, you get some small line under your values when these values are very close in your bar chart. Right?


In Reporting Services, even having same values and label displayed, we didn't find any lines displayed in bar chart when we tested in our environment. Could you please post some detail information and screenshots about your report if possible. This may help us reproduce your issue in our local lab. Thank You.


Reference:

Bar Charts (Report Builder and SSRS)


Best Regards,

Simon Hou


Try to upload a WSP file to Solution gallery, got the The URL '/File name' is invalid error

I tried to upload a WSP file to Solution Gallery and an error: “The URL '<Doc lib>/File name' is invalid. It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web”


We have checked the SQL server disc space, which still has plenty of spase left; reset IIS server, still not working.


Please advise...Thanks in advance.





Feng Wan


Library placement when developing with sqlite

Not sure I understand your question correctly. You can use Nuget. It will get your dll on demand if this is what you are looking.


http://ift.tt/mZrRdB


chanmm




chanmm


Bucket data

Here's the full illsutration using a sample table



ALTER DATABASE DBName ADD FILEGROUP [Filegroup1]
GO
ALTER DATABASE DBName ADD FILEGROUP [Filegroup2]
GO
ALTER DATABASE DBName ADD FILEGROUP [Filegroup3]
GO
ALTER DATABASE DBName ADD FILEGROUP [Filegroup4]
GO
ALTER DATABASE DBName ADD FILEGROUP [Filegroup5]
GO
ALTER DATABASE DBName ADD FILEGROUP [Filegroup6]
GO
ALTER DATABASE DBName ADD FILEGROUP [Filegroup7]
GO
ALTER DATABASE DBName ADD FILEGROUP [Filegroup8]
GO
ALTER DATABASE DBName ADD FILEGROUP [Filegroup9]
GO
ALTER DATABASE DBName ADD FILEGROUP [Filegroup10]
GO

ALTER DATABASE DBName
ADD FILE
(NAME = N'data1',
FILENAME = N'<full path>\data1.ndf',
SIZE = 5000MB,
MAXSIZE = 10000MB,
FILEGROWTH = 500MB)
TO FILEGROUP [Filegroup1]
GO
ALTER DATABASE DBName
ADD FILE
(NAME = N'data2',
FILENAME = N'<full path>\data2.ndf',
SIZE = 5000MB,
MAXSIZE = 10000MB,
FILEGROWTH = 500MB)
TO FILEGROUP [Filegroup2]
GO
ALTER DATABASE DBName
ADD FILE
(NAME = N'data3',
FILENAME = N'<full path>\data3.ndf',
SIZE = 5000MB,
MAXSIZE = 10000MB,
FILEGROWTH = 500MB)
TO FILEGROUP [Filegroup3]
GO
ALTER DATABASE DBName
ADD FILE
(NAME = N'data4',
FILENAME = N'<full path>\data4.ndf',
SIZE = 5000MB,
MAXSIZE = 10000MB,
FILEGROWTH = 500MB)
TO FILEGROUP [Filegroup4]
GO
ALTER DATABASE DBName
ADD FILE
(NAME = N'data5',
FILENAME = N'<full path>\data5.ndf',
SIZE = 5000MB,
MAXSIZE = 10000MB,
FILEGROWTH = 500MB)
TO FILEGROUP [Filegroup5]
GO
ALTER DATABASE DBName
ADD FILE
(NAME = N'data6',
FILENAME = N'<full path>\data6.ndf',
SIZE = 5000MB,
MAXSIZE = 10000MB,
FILEGROWTH = 500MB)
TO FILEGROUP [Filegroup6]
GO
ALTER DATABASE DBName
ADD FILE
(NAME = N'data7',
FILENAME = N'<full path>\data7.ndf',
SIZE = 5000MB,
MAXSIZE = 10000MB,
FILEGROWTH = 500MB)
TO FILEGROUP [Filegroup7]
GO
ALTER DATABASE DBName
ADD FILE
(NAME = N'data8',
FILENAME = N'<full path>\data8.ndf',
SIZE = 5000MB,
MAXSIZE = 10000MB,
FILEGROWTH = 500MB)
TO FILEGROUP [Filegroup8]
GO
ALTER DATABASE DBName
ADD FILE
(NAME = N'data9',
FILENAME = N'<full path>\data9.ndf',
SIZE = 5000MB,
MAXSIZE = 10000MB,
FILEGROWTH = 500MB)
TO FILEGROUP [Filegroup9]
GO
ALTER DATABASE DBName
ADD FILE
(NAME = N'data10',
FILENAME = N'<full path>\data10.ndf',
SIZE = 5000MB,
MAXSIZE = 10000MB,
FILEGROWTH = 500MB)
TO FILEGROUP [Filegroup10]
GO



--create partition function
CREATE PARTITION FUNCTION BucketPartitionFN (int) AS
RANGE LEFT FOR VALUES
( 1,2,3,4,5,6,7,8,9)

--create partition scheme
CREATE PARTITION SCHEME BucketScheme AS
PARTITION BucketPartitionFN TO
(
[Filegroup1],
[Filegroup2],
[Filegroup3],
[Filegroup4],
[Filegroup5],
[Filegroup6],
[Filegroup7],
[Filegroup8],
[Filegroup9],
[Filegroup10]
)


--Now create sample table based on scheme
create table PartitionTest
(
ID int IDENTITY(1,1),
Val int,
BucketNo int
)
ON BucketScheme(BucketNo)

--populate some sample data
;WITH T1 AS (SELECT 1 N UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1),
T2 AS (SELECT 1 N FROM T1 a,T1 b),
T3 AS (SELECT 1 N FROM T2 a,T2 b),
T4 AS (SELECT 1 N FROM T3 a,T3 b),
Numbers AS (SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS Seq FROM T4)


INSERT PartitionTest (Val,BucketNo)
SELECT Seq,NTILE(10) OVER (ORDER BY Seq)
FROM Numbers


--Check the partitions where data resides with recordcount
SELECT $partition.BucketPartitionFN(BucketNo) AS PartitionNo,MIN(BucketNo) AS StartBucketNo,MAX(BucketNo) AS EndBucketNo,COUNT(*) AS RecordCount
FROM PartitionTest
GROUP BY $partition.BucketPartitionFN(BucketNo)





just replace DBName and path in above script and you will see it splits up data into 10 partitions based on Bucket value




Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


How to add a SubReport from a MainReport in rdlc.

Hi Vinoc4,


According to your description, you want to have an image "button" only for the last record in your report, and use this "button" to call a subreport. Right?


In Reporting Services, we can add a subreport into a report and set the subreport toggled by a report item in visibility setting. However, this report item can't be a dynamic textbox in a detail row, it should be a static one. Since you only want the subreport be called by the last record, we suggest you add a row out side of group, then set the subreport toggled by the textbox in the added row. We have tested this case in our local environment. It looks like below:



Reference:

Add an Expand/Collapse Action to an Item (Report Builder and SSRS)


If you have any question, please feel free to ask.


Best Regards,

Simon Hou




Workflow.asmx AtlerTodo

Hi,


The following code snippet for your reference:



int todoID =int.Parse(todoNode.Attributes.GetNamedItem("ows_ID").Value);
Guid tasklistID = new Guid(todoNode.Attributes.GetNamedItem("ows_TaskListId").Value);

XmlDocument doc = new XmlDocument();

StringBuilder xmlBuilder = new StringBuilder();
xmlBuilder.Append("<wor:taskData>");
xmlBuilder.AppendFormat("<my:myFields xmlns:my= \"{0}\">", "http://ift.tt/1jzoDez;);
xmlBuilder.Append("<my:TaskStatus />");
xmlBuilder.Append("<my:Comments />");
xmlBuilder.Append("<my:DelegateTo>");
xmlBuilder.Append("<my:Person>");
xmlBuilder.AppendFormat("<my:DisplayName>{0}</my:DisplayName>", "UserName");
xmlBuilder.AppendFormat("<my:AccountId>{0}</my:AccountId>", "UserLoginName");
xmlBuilder.AppendFormat("<my:AccountType>{0}</my:AccountType>", "User");
xmlBuilder.Append("</my:Person>");
xmlBuilder.Append("</my:DelegateTo>");
xmlBuilder.AppendFormat("<my:NewDescription>{0}</my:NewDescription>", "Description");
xmlBuilder.AppendFormat("<my:NewDueDate>2012-11-21 11:21:00</my:NewDueDate>");
xmlBuilder.Append("<my:RequestTo />");
xmlBuilder.Append("<my:Decline />");
xmlBuilder.Append("<my:dcr />");
xmlBuilder.AppendFormat("<my:Status>{0}</my:Status>", "Status");
xmlBuilder.Append("</my:myFields>");
xmlBuilder.Append("</wor:taskData>");

doc.LoadXml(xmlBuilder.ToString());

XmlNode node = ws.AlterToDo("http://moss/sitedirectory/msdn/shared documents/doc1.docx",
todoID, tasklistID, doc);

More information:

http://ift.tt/1jzoDeB


Best regards




Dennis Guo

TechNet Community Support



Partition Table with Data in Place

Thanks Erland,


Everything seems to be in order to me but I wanted confirmation that I hadn't missed anything.


I only reindexed the subject PK by the way,so I do still wonder whether it was necessary.




R Campbell



Partition Table with Data in Place


I only reindexed the subject PK by the way,so I do still wonder whether it was necessary.



That should of course not be necessary - but you should reindex the tables that still are in the primary filegroup.





Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Image not included in my PrintDocument

Do you have a whole project I can work with? Please upload to OneDrive and paste a link here.


Matt Small - Microsoft Escalation Engineer - Forum Moderator

If my reply answers your question, please mark this post as answered.



NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.


CS1690:Accessing a member on 'member' may cause a runtime exception because it is a field of a marshal-by-reference class

I am having the same problem.


This is the code:



frmEmployeeContactEntry EmployeeContactEntryForm = new frmEmployeeContactEntry(public_var);
EmployeeContactEntryForm.employee_id = employee_id;

DialogResult employee_contact_form = EmployeeContactEntryForm.ShowDialog();

if (employee_contact_form == System.Windows.Forms.DialogResult.OK)
{
gridContacts.AddNewRow();
gridContacts.SetRowCellValue(gridContacts.FocusedRowHandle, "contact_id", EmployeeContactEntryForm.employee_contact_id.ToString());
gridContacts.SetRowCellValue(gridContacts.FocusedRowHandle, "contact_category_name", EmployeeContactEntryForm.cboCategory.Text);
gridContacts.SetRowCellValue(gridContacts.FocusedRowHandle, "contact_details", EmployeeContactEntryForm.txtContact.Text.Trim());
gridContacts.SetRowCellValue(gridContacts.FocusedRowHandle, "contact_description", EmployeeContactEntryForm.txtDescription.Text.Trim());
}



and the error occurs on this code:



EmployeeContactEntryForm.employee_contact_id.ToString()

employee_contact_id is an int in frmEmployeeContactEntry


public int employee_contact_id;


How can I fix it please


EmployeeContactEntryForm.employee_contact_id.ToString()

EmployeeContactEntryForm.employee_contact_id.ToString()

Conversion failed when converting the varchar value '5,6' to data type int.

Here is how you can find the culprit faster than Sherlock Holmes: Just comment out the suspect line.


What is the data type?



SELECT GGI.IID ID
, G.GrantNum
, PA.ProgramArea
, G.GranteeName
, G.Project
, L2.Description Race
FROM TGrant G
INNER JOIN TGrant_GranteeInfo GGI ON G.IID=GGI.GrantIID
left join TProgramArea PA on G.ProgramAreaIID=PA.IID
right join TLookup L2 on L2.Code=GGI.TargetRace_Codes and L2.FieldName='TargetRace'
WHERE G.GrantType='CSAT'
-- AND GGI.TargetRace_Codes IN (1,2,3,4,5,6,7)
ORDER BY PA.ProgramArea





Kalman Toth Database & OLAP Architect SQL Server 2014 Design & Programming

New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012















Conversion failed when converting the varchar value '5,6' to data type int.

Can you try the below code?



DECLARE @no varchar(2)='23'
select getdate()
where CAST(@no as int)=23




SELECT GGI.IID ID
, G.GrantNum
, PA.ProgramArea
, G.GranteeName
, G.Project
, L2.Description Race
FROM TGrant G
INNER JOIN TGrant_GranteeInfo GGI ON G.IID=GGI.GrantIID
left join TProgramArea PA on G.ProgramAreaIID=PA.IID
right join TLookup L2 on L2.Code=GGI.TargetRace_Codes and L2.FieldName='TargetRace'
WHERE G.GrantType='CSAT'
AND cast(GGI.TargetRace_Codes as int)IN (1,2,3,4,5,6,7)
ORDER BY PA.ProgramArea



--Prashanth


Conversion failed when converting the varchar value '5,6' to data type int.

When ever you get data from multivalued checkbox, atleast in SSRS it will come as a String '1,2,3,4,5,6'. You will have to split the string with a function and then you can run the query. Otherwise, the CAST will try to cast 1,2,3,4,5 as INT which is invalid



SELECT *
FROM Table
WHERE Condition IN(SELECT ParsedValues
FROM dbo.splitString(inputString))


Conversion failed when converting the varchar value '5,6' to data type int.

Thanks,


I will give your suggestion a whirl.


Conversion failed when converting the varchar value '5,6' to data type int.

Hello,


I 'm writing yo follow up with you on this post.

Was the problem resolved? Did you try the solution as Prashanth post above to convert the data type of the column [targetrace_codes]? Or you can try to change the data type of the multiple_value parameter to string.


If there is any misunderstanding, please post more details for further analysis.


Regards,

Fanny Liu




Fanny Liu

TechNet Community Support



Partition Table with Data in Place

Thanks Erland,


Everything seems to be in order to me but I wanted confirmation that I hadn't missed anything.


I only reindexed the subject PK by the way,so I do still wonder whether it was necessary.




R Campbell



How to detrimine date duration, minus weekend days and days on hold

This?



;With CTE
AS
(
SELECT ROW_NUMBER() OVER (PARTITION BY [UNIVERSL_ID] ORDER BY LOG_DATESTAMP) AS Seq,*
FROM Reporting_Duration2
)

SELECT c1.[UNIVERSL_ID],
MAX(DATEDIFF(dd,c1.T_MILESTONE_3,COALESCE(c1.T_MILESTONE_8,c1.T_MILESTONE_7)) + 1 - (DATEDIFF(wk,c1.T_MILESTONE_3,COALESCE(c1.T_MILESTONE_8,c1.T_MILESTONE_7)) *2) - CASE WHEN DATEDIFF(dd,0,c1.T_MILESTONE_3)% 7 > 4 THEN 1 ELSE 0 END - CASE WHEN DATEDIFF(dd,0,COALESCE(c1.T_MILESTONE_8,c1.T_MILESTONE_7))% 7 > 4 THEN 1 ELSE 0 END) AS [Duration (Minus Weekends)],
SUM(CASE WHEN c1.OPEN_OH IS NOT NULL AND c2.OH_OPEN IS NOT NULL THEN DATEDIFF(dd,c1.OPEN_OH,c2.OH_OPEN) + 1 - (DATEDIFF(wk,c1.OPEN_OH,c2.OH_OPEN) *2) - CASE WHEN DATEDIFF(dd,0,c1.OPEN_OH)% 7 > 4 THEN 1 ELSE 0 END - CASE WHEN DATEDIFF(dd,0,c2.OH_OPEN)% 7 > 4 THEN 1 ELSE 0 END
ELSE 0 END) AS [Duration On Hold (minus Weekends)],
(MAX(DATEDIFF(dd,c1.T_MILESTONE_3,COALESCE(c1.T_MILESTONE_8,c1.T_MILESTONE_7)) + 1 - (DATEDIFF(wk,c1.T_MILESTONE_3,COALESCE(c1.T_MILESTONE_8,c1.T_MILESTONE_7)) *2) - CASE WHEN DATEDIFF(dd,0,c1.T_MILESTONE_3)% 7 > 4 THEN 1 ELSE 0 END - CASE WHEN DATEDIFF(dd,0,COALESCE(c1.T_MILESTONE_8,c1.T_MILESTONE_7))% 7 > 4 THEN 1 ELSE 0 END))-(SUM(CASE WHEN c1.OPEN_OH IS NOT NULL AND c2.OH_OPEN IS NOT NULL THEN DATEDIFF(dd,c1.OPEN_OH,c2.OH_OPEN) + 1 - (DATEDIFF(wk,c1.OPEN_OH,c2.OH_OPEN) *2) - CASE WHEN DATEDIFF(dd,0,c1.OPEN_OH)% 7 > 4 THEN 1 ELSE 0 END - CASE WHEN DATEDIFF(dd,0,c2.OH_OPEN)% 7 > 4 THEN 1 ELSE 0 END
ELSE 0 END)) AS [TotalDays]
FROM CTE c1
INNER JOIN CTE c2
ON c2.[UNIVERSL_ID] = c1.[UNIVERSL_ID]
AND c2.Seq = c1.Seq + 1
GROUP BY c1.[UNIVERSL_ID]





Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


Active Directory Import

Dear Experts


I have a problem with user profile sync service. System admins made some changes to user profiles in active directory. I want to import these changes to SharePoint 2013. I followed the instructions listed here:


http://ift.tt/15GQJzu


but also no results.


Any advices???


Active Directory Import

Yes I made a mistake. Actually I am talking about Active Directory Import.

Universal App Mulitiple Page

Hi,

You can add a page in the shared and this page will work on both platform, but you need to consider the design issues like the title and size of the controls on every platform (Also some controls are working in W8 and aren't in WP and opposite) also some libraries are working on a platform and not working on the other.


So here some solution


1) On the controls that its size should vary from one platform to another you should add a user control for it in every project.


2) In the code behind if a library is working in Windows 8 you can write it within block #if WINDOWS_APPS

#endif


and for WP


#if WINDOWS_PHONE_APP

#endif


And my recommendation is if the page will change a lot from one platform to another in UI and code, you should add a page form every platform,


if not the user control and #if block will save a lot of time.


Regards,




Ibraheem Osama Mohamed | My Blog | @IbraheemOM | My Website



(If my reply answers your question, please propose it as an answer)


Issue with creating the Body in VCALENDAR format

Have you check this?


http://ift.tt/1qZvkhr


Convert VB to C# code.


chanmm




chanmm


Installation in a Specified Project and Usercontrol

Goal:

Install the package in a specific project or usercontrol. You can read the instructions in this link (http://ift.tt/XYAMm2).


Problem:

How should I write the code that make package will be installed in a specified project or usercontrol?

The installation shall not be applied in the startup project.


Information:

- http://ift.tt/1mGdwFp

- http://ift.tt/XYAMm2



Installation in a Specified Project and Usercontrol

We use Nuget for dll. I am not sure whether it is good idea to use for Usercontrol. Somehow the UserControl should be part of the build and included during the design time.


chanmm




chanmm


Provide access to Custom Control Method

Hi Talha,


I don't get what you want to do. It would be helpful to have some code that shows what you're doing and where the problem is. :)




Thomas Claudius Huber



"If you can't make your app run faster, make it at least look & feel extremly fast"



My latest app: The "Womanizer" :-)

twitter: @thomasclaudiush

homepage: http://ift.tt/1fArvuE

author of: ultimate Windows Store Apps handbook | ultimate WPF handbook | ultimate Silverlight handbook


Provide access to Custom Control Method


Hi Talha,


I don't get what you want to do. It would be helpful to have some code that shows what you're doing and where the problem is. :)




Thomas Claudius Huber



"If you can't make your app run faster, make it at least look & feel extremly fast"



My latest app: The "Womanizer" :-)

twitter: @thomasclaudiush

homepage: http://ift.tt/1fArvuE

author of: ultimate Windows Store Apps handbook | ultimate WPF handbook | ultimate Silverlight handbook




<UserControl
x:Class="CustomControls.CustomListView"
xmlns="http://ift.tt/w9rHWX;
xmlns:x="http://ift.tt/zZkFEV;
xmlns:local="using:CustomControls"
xmlns:d="http://ift.tt/PuXO1J;
xmlns:mc="http://ift.tt/R4RR6u;
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">



<ListView x:Name="RootListView"
SelectionMode="Extended"
CanDragItems="True"
SelectionChanged="SelectionChanged"
AllowDrop="True"
DragItemsStarting="RootListView_DragItemsStarting"
Drop="DragDropped"
Header="{Binding Header}"
HeaderTemplate="{Binding HeaderTemplate}"
ItemsPanel="{Binding ItemsPanel}"
Background="{Binding ActualBackground}"
ItemsSource="{Binding ItemsSource}"
Foreground="{Binding ActualForeground}"
BorderThickness="{Binding ActualBorderThickness}"
BorderBrush="{Binding ActualBorderBrush}"
ItemTemplate="{Binding ItemTemplate}"
ContainerContentChanging="ItemsChanged"
>
</ListView>
</UserControl>

I have a control like this. To expose the properties of inner control, I used binding. So, the user of CustomListView can change properties of inner ListView by changing CustomListView properties. Now, I have written a EventHandler for "Checkbox.Checked" and "Checkbox.Unchecked" in code behind of CustomListView.(Say EventHandler is named CheckChangedHandler)


CustomListView can be used like this:



<Page xmlns="http://ift.tt/w9rHWX;
xmlns:x="http://ift.tt/zZkFEV;
xmlns:local="using:TimeTable_c_sharp"
xmlns:Controls="using:CustomControls"
xmlns:d="http://ift.tt/PuXO1J;
xmlns:mc="http://ift.tt/R4RR6u;
xmlns:ProjectClasses="using:ProjectClasses"
xmlns:UI="using:Microsoft.Advertising.WinRT.UI"
x:Class="TimeTable_c_sharp.MainPage"
mc:Ignorable="d">

<Page.Resources>
<Style TargetType="Controls:CustomListView" x:Key="CListViewStyle1">
<Setter Property="Height" Value="346" />
<Setter Property="Width" Value="425" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="AllowDrop" Value="True" />
<Setter Property="ActualBackground" Value="#FF1D2E42" />
<Setter Property="ActualBorderBrush" Value="#FF575757" />
<Setter Property="ActualBorderThickness" Value="1" />
</Style>

<DataTemplate x:Key="AllSubjectsHeaderTemplate">
<Border BorderBrush="#FF677E7B"
BorderThickness="0,0,0,1"
Background="#FF534C4C">
<StackPanel Orientation="Horizontal">
<CheckBox x:Name="checkBox"
HorizontalAlignment="Left"
Margin="10"
VerticalAlignment="Top"
IsChecked="{Binding IsChecked, Mode=TwoWay}"
Width="27" />

<TextBlock Grid.Column="1"
TextAlignment="Center"
Text="{Binding Content.Column1, RelativeSource={RelativeSource Mode=TemplatedParent}}"
Margin="22,10,0,0"
TextWrapping="Wrap"
FontStyle="Normal"
FontWeight="Bold"
FontSize="18"
VerticalAlignment="Top"
Width="298"
Height="24"
x:Name="Header1"
Foreground="#FFB2BF8F" />
</StackPanel>
</Border>
</DataTemplate>
</Page.Resources>

<Controls:CustomListView x:Name="allSubjectsList"
Margin="266,141,0,0"
Header="{Binding AllSubjectsHeader}"
ItemsSource="{Binding AvailibleSubjects}"
Style="{StaticResource CListViewStyle1}"
HeaderTemplate="{StaticResource AllSubjectsHeaderTemplate}"
/>
</Page>



As you can see, user can change templates of CustomListView->RootListView. Now, there is a checkbox in Datatemplate user applied as HeaderTemplate. I want to give user ability to add following line in that checkbox.



<CheckBox Checked=<!-- Event Handler for check changed defined in CustomListView code behind -->
/>

Hope, you understands this.