Thursday, August 29, 2013

SQL Server Data Tools - Update to open Database Project

When tried to open a SQL database project in Visual Studio 2012 Update 2, I encountered with the following error message.



My search ended up with updating SQL Server Data Tools for Visual Studio 2012 which I used this MSDN link to load and set it up, the problem solved.

Share/Bookmark

Clustered SQL server - Get the current node name of running instance

One way to get the current node name of running instance of clustered SQL server would be to execute the following scripts:

--Check SQL Server instance name SELECT @@SERVERNAME --Check the name of the node on which the clustered -- SQL Server instance is running on SELECT SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS [CurrentNodeName]


Alternatively, you may run Server manager (right click on "Computer" in start menu and choose "Manage"), then
Features -> Failover Cluster Manager -> [The cluster name] -> Services and applications -> SQL server

It shows details and the "Current Owner" shows the node which SQL server is running on that node.
Share/Bookmark

Wednesday, August 28, 2013

Query all SSRS Reports, shared and embeded Datasources, and locations

As the SSRS reports details are available in ReportServer DB, sometime that's a good idea to take a look into reports' detail such as data sources which in some point may help to make a better decision to keep them embedded or utilize a shared one.

By customizing the folllowing script easily more information can be queried.

Use ReportServer GO ;WITH SSRS_Rprt_DtaSrc AS ( SELECT Catalog.Name AS [Report Name] , Catalog.path AS [Report Location] , DataSource.Name AS [Data Source Name] , DataSource.Link AS Link FROM [Catalog] INNER JOIN DataSource ON Catalog.ItemID = DataSource.ItemID ) SELECT [Report Name] , [Report Location] , [Data Source Name] , Ctlg.Name AS [Data Source Item] FROM SSRS_Rprt_DtaSrc INNER JOIN [Catalog] AS Ctlg ON SSRS_Rprt_DtaSrc.Link = Ctlg.[ItemID] ORDER BY [Report Location]

Share/Bookmark

Friday, August 23, 2013

Microsoft iSCSI Software Target 3.3 (MS Windows Server 2008 R2)

Needed to install SQL server clusters, then it needs shared data to be used as centralized disk subsystem by SQL nodes in the cluster, the feature is build in by MS Windows Server 2012 but for MS Windows Server 2008 R2 it’s available as a download in Download Center if you search for “iSCSI Target” which is free.



By clicking on “iSCSI Software Target” it downloads a .msi and install it. After running, right click on device and choose “Create Virtual Disk”.



Choose a file name for the Virtual disk which has .vhd extension and click on Next.



Set the Virtual disk size and click on Next.



Possible to write a description too (optional) and click on Next.



Now bypass adding iSCSI targets by clicking on Next as targets are not defined yet and after that click on Finish.



The Virtual disk is ready:



Right click, on “iSCSI Target” and then “Create iSCSI Target”



Then choose a name:



Better to address the target by IP, then click on Advanced, choose “Add”, and now choose “IP Address” and enter the IP and click to finish this part



Now the target is available:



Then assign the Target to Device by right clicking on the Virtual Disk and choose “Assign/Remove Target”



Click on Add in Target Access tab:



Choose the Target and click on Ok and close the window. It’s done now you can use it in the Target side.
Connect to remote system, choose “Administrative Tools” and choose “iSCSI Initiator” Enter IP address of target In Target text box and click on Quick Connect



Quick connect window discovers target, now click on Done.



Now choose “Volumes and Devices” tab



The device adds in Volume list:



Click on OK and close the window



now right click on the disk and click on Online then right click again and choose “Initialize Disk”, right after right click on new disk and choose “New Simple Volume” to set a letter and format the volume which make it available immediately.


Share/Bookmark

Wednesday, August 14, 2013

ASP.NET MVC and SQL Server Reporting Services

ASP.NET MVC and SQL Server Reporting Services If you need to view a SSRS type report in ASP.NET MVC application one way would be to have a Controller action method to launch report and an ASP.NET Web Form to host the Report Viewer control. Then the action method redirects to the .aspx page which contains the report viewer control and passes necessary parameters for report's query filter. The sample code is as following:

".ASPX web form page who contains ReportViewer control"
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" Height="768px" ProcessingMode="Remote" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="1024px"> <ServerReport ReportPath="/REPORTS_FOLDER/REPORT_NAME" ReportServerUrl="http://YOUR_SSRS_SERVER/reportserver" /> </rsweb:ReportViewer> </form> </body> </html>

using System.Web.UI; using System.Web.UI.WebControls; using Microsoft.Reporting.WebForms; ... protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { var rprtPrms = (Dictionary) Session["reportParameters"]; foreach (var item in rprtPrms) { ReportViewer1.ServerReport.SetParameters( new List() { new ReportParameter(item.Key, item.Value.ToString()) } ); } } }

"The action in the controller"
public ActionResult Index() { var rprtPrms = new Dictionary(); rprtPrms.Add("MyReportParameter", 6); Session["reportParameters"] = rprtPrms; return Redirect("/RprtViewer.aspx"); }

Share/Bookmark

Tuesday, August 13, 2013

SSRS Report - Showing Header objects only on First Page

To hide the header objects (textboxes, images) that hold the header information on pages other than first one it's possible to control visibility of objects by a conditional expression lok like the following one:
=iif(Globals!PageNumber = 1, FALSE, TRUE)

The expression property will be accessible with below steps:
right-click on the header object (Image, text box) -> choose properties -> visibility -> select "Show or hide based on expression" -> insert expression above


Share/Bookmark

Adding a Page Break after a Sub-report (SSRS report)

I needed to break the page after a sub-report to force the next sub report to be shown in next page.

One way which was fit for my case comes simply as following:

- Added a rectangle onto my report and position it just below the sub-report.
- Resized the rectangle to only one pixel tall.
- In properties windows of the Rectangle object, set the PageBreak->BreakLocation property to Start.


Share/Bookmark

Tuesday, August 6, 2013

WCF service under Network Load Balancing (NLB)

To use WCF services on multi servers under Network Load Balancing one solution would be utilizing BasicHttpBinding as WCF channels that use this binding are inherently stateless, and terminate their connections when the channel closes.

In message Http header of BasicHttpBinding the Keep-Alive value is true by default which helps to keep persistent connections into services to reuse by sending messages to the same server that improves performance of services. The side effect is the cause of associating clients to specific server which reduces the effectiveness of load balancing. Setting KeepAliveEnabled value to false within a CustomBinding allows NLB functions correctly without sticky session and server affinity.

using (var srv = new SrvClient("BasicHttpLB")) { #region Custom binding to disable [Keep Alive] property of transport Element var wcfsrvCstmBndng = new CustomBinding(svcBinding); var bindingTransportElement = wcfsrvCstmBndng.Elements.Find< HttpTransportBindingElement>(); bindingTransportElement.KeepAliveEnabled = false; // Disable [Keep Alive] property of Transport Element #endregion srv.Endpoint.Binding = wcfsrvCstmBndng; .... //Calling service operations and do what's necessary }

Share/Bookmark

Thursday, August 1, 2013

.NET Framework Version (including 4.0+)

As the .NET Framework 4.5 is an in place update then it updates assemblies if .NET 4.0 is already installed, the best way to find out available .NET framework versions in the system would be checking it in registry.

The following code is executable directly in LinqPad too, you can get the perfect LinqPad tool (free) by (Joseph Albahari) here.

// Microsoft.Win32 // System void Main() { RegistryKey ndpKey = RegistryKey.OpenBaseKey( RegistryHive.LocalMachine , RegistryView.Registry32).OpenSubKey( @"SOFTWARE\Microsoft\NET Framework Setup\NDP\"); foreach (string verKeyName in ndpKey.GetSubKeyNames()) { if (verKeyName.StartsWith("v")) { RegistryKey verKey = ndpKey.OpenSubKey(verKeyName); string name = (string)verKey.GetValue("Version", ""); string sp = verKey.GetValue("SP", "").ToString(); string install = verKey.GetValue("Install", "").ToString(); if (install == "") Console.WriteLine( verKeyName + " " + name); else if (sp != "" && install == "1") Console.WriteLine( verKeyName + " " + name + " SP" + sp); if (name != "") continue; foreach (string subKeyName in verKey.GetSubKeyNames()) { RegistryKey subKey = verKey.OpenSubKey(subKeyName); name = (string)subKey.GetValue("Version", ""); if (name != "") sp = subKey.GetValue("SP", "").ToString(); install = subKey.GetValue("Install", "").ToString(); if (install == "") Console.WriteLine(verKeyName + " " + name); else if (sp != "" && install == "1") Console.WriteLine( " " + subKeyName + " " + name + " SP" + sp); else if (install == "1") Console.WriteLine( " " + subKeyName + " " + name); } } } }

Share/Bookmark