Monday, December 24, 2018

ASP.NET MVC: HTML.ACTIONLINK VS URL.ACTION

@Html.ActionLink generates anchor  <a> tag or hyperlink on a view page in MVC whereas @Url.Action returns only a qualified URL. 

HTML.Actionlink() : 

HTMLHelper (@Html) object uses ActionLink() method to render the anchor HTML element with specified link text and action /controller name.


Here is an example of HTML.ActionLink() method to generate a hyperlink with action/controller name:

@Html.ActionLink("Home""Home""Person"

It Generates <a href="/Person/Home" >Home</a>

@Html.ActionLink("Product""Detail""Product", new { id ="5668"}, null

It Generates: < a href="https://www.blogger.com/product/detail/5678" > Product </a>


URL.Action ():

URL.Action method is used to generate the qualified URL by using the action and controller name with routes value.

Here is an example of URL.Action() method:

Url.Action("detail", "product", new { id = "5678" })

It Generates:  /product/detail/5678

More information about URL.Action @  MSDN : UrlHelper.Action Method


Friday, December 21, 2018

ASP.NET MVC : Anchor Tag IN MVC Razor View


In this blog we will discuss about the @HTMLHelper class and how to create the HTML Anchor by using @Html.ActionLink.

@HTMLHelper Class:

@Html is used in ASP.NET MVC to render HTML elements like TextBox, Button etc. and it binds the model object to HTML control and display the object’s value and while posting the page, it binds the control value to model object.


@Html.ActionLink Method:

HTMLHelper object has ActionLink method to render the anchor HTML element with specified link text and action name with controller.


Here is examples of Action methods:

·        @Html.ActionLink("Home""Home""Person"

Generates <a href="/Person/Home" >Home</a>


·         IF you are not passing controller, by default it will take current page controller name.


    @Html.ActionLink("Home""Home")


·         Action and Controller with parameter are given:


@Html.ActionLink("Home""Home""Person"new { PersonID = Model.ID}, null )


Generates <a href="../Person/Home?PersonID=1212" >Home</a>


·         Anchor with html ID


@Html.ActionLink("Home""Home""Person"new { PersonID = Model.ID}, new { id = "HomeLinkID"} )


Generates <a href="../Person/Home?PersonID=1212" id="HomeLinkID" >Home</a>

Thanks for visiting!!

Thursday, December 13, 2018

SSIS: Dynamic File Name for Flat File Destination


This blog will demonstrates how to give the dynamic file name for flat or csv  file in SSIS package  like DataFeed_{yyyyMMdd} .txt eg. DataFeed_20181212.txt




Data Flow
Data Flow

  • Configure the Flat File Destination with dummy file name.
Flat File Connection Manager
Flat File Connection Manager
  • Go to Connection Manager and right click on Flat File Connection Manager

    1. Click on Property
    2. Set DelayValidation = True, by default it is False

Flat File Connection Manager Property
Flat File Connection Manager Property
  • Click on Expression Property and Set Expression Value for ConnectionString 


Expression Builder
Expression Builder































Expression:

"C:\\temp\\dataFeed_"+(DT_STR,4,1252)MONTH( DATEADD( "dd", -1, getdate() )) +(DT_STR,4,1252)DAY( DATEADD( "dd", -1, getdate() )) +(DT_STR,4,1252)YEAR( DATEADD( "dd", -1, getdate() ))+".txt"


·   (DT_STR,4,1252)MONTH( DATEADD( "dd", -1, getdate() )) – returns Month
·   (DT_STR,4,1252)DAY( DATEADD( "dd", -1, getdate() )) – returns day
·   (DT_STR,4,1252)YEAR( DATEADD( "dd", -1, getdate() )) – returns Year
  
The above expression generates file name dataFeed_MMDDYYYY.txt in C:\temp location.


Thanks for visiting and please leave your comment if it helps you

Tuesday, December 11, 2018

SSRS : RDLC - NULL Check, Date Format and Concatenate of Fields

this blog discuss about the basic operation like how to concatenate two fields or NULL check or convert string into uppercase or format date/time field in rdlc .

Concatenate two Fields Value :  
We can simply concatenate two string field as below

Example:
 =Fields!Description.Value +"("+Fields!Code.Value+")"

NULL Check of Field Value:
We can use IS Nothing statement to check field NULL value.

Example:
 =iif(Fields!Letter.Value Is Nothing, “No Letter Found”,Fields!Letter.Value)



Date Format:
We can use FormatDateTime() function to format date/time field value.

Example:
=FormatDateTime(Fields!OrderDate.Value, DateFormat.ShortDate))

Options for Dateformat : 
  • GeneralDate
  • LongDate
  • ShortDate
  • LongTime
  • ShortTime 
UpperCase of Field Value:
We can use  UCase() function to convert the string or character containing the specified string  into uppercase.

Exmaple :
=UCase(Fields!Description.Value)

Thanks For Visiting !!

Visual Studio SSIS Project Incompatible


Unsupported
This version of Visual Studio is unable to open the following projects. The project types may not be installed or this version of Visual Studio may not support them.
For more information on enabling these project types or otherwise migrating your assets, please see the details in the "Migration Report" displayed after clicking OK.

I recently faced this issue, when I tried to open existing SSIS project and it was not opening in Visual Studio 2017 and throwing ‘Unsupported Message’.
When I migrated current project from visual 2015 to visual 2017 and I found that SSIS /SSRS component is not part of Visual studio 2017 installation package so I installed separate package for SSIS/SSRS and after sometimes visual studio (in background ) runs some performance improvement update checks and it asks to disabled the 3rd party component and after that SSIS package was not loading in visual studio solution  and throwing above unsupported error message.



 I followed below steps to resolve this problem. 

Click on Tools à Extensions and Updates … Option 

Extensions and Updates
Extensions and Updates


Extensions and Updates Screen:
  
Extensions and Updates







Click on “Enable” button to include package in project, after that close visual studio solution and reopen the SSIS project.


Thanks for visiting and please leave your comments, if it helps you

SQL Server - Identify unused indexes

 In this blog, we learn about the index usage information (SYS.DM_DB_INDEX_USAGE_STATS) and analyze the index usage data (USER_SEEKS, USER_S...