tag:blogger.com,1999:blog-49507641936089053052024-03-08T04:03:27.277-08:00Tech WorldRajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.comBlogger85125tag:blogger.com,1999:blog-4950764193608905305.post-25038745329707517132020-04-27T08:34:00.002-07:002020-04-27T08:34:24.001-07:00looping with Pipe<div dir="ltr" style="text-align: left;" trbidi="on">
WHILE LEN(@CandidateIds) > 0<br />
BEGIN<br />
<span style="white-space: pre;"> </span>IF PATINDEX('%|%',@CandidateIds) > 0<br />
<span style="white-space: pre;"> </span>BEGIN<br />
<span style="white-space: pre;"> </span>SET @CandidateId = CONVERT(BIGINT,(SUBSTRING(@CandidateIds, 0, PATINDEX('%|%',@CandidateIds))))<br />
<span style="white-space: pre;"> </span>-- print @CandidateId<br />
<span style="white-space: pre;"> </span>EXEC Proc @CandidateId,@FK_CorporateId,@FK_ProgramId,@Interview_DateTime,@Interview_Venue,@Interview_Remarks,@intInvitationStatus,@ReturnValue OUTPUT<br />
<span style="white-space: pre;"> </span>SET @CandidateIds = SUBSTRING(@CandidateIds, LEN(CONVERT(VARCHAR(20),@CandidateId) + '|') + 1, LEN(@CandidateIds))<span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> </span>IF(@ReturnValue != 0 AND @ReturnValue != -1)<br />
<span style="white-space: pre;"> </span>BEGIN<span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> </span>SET @DublicateCandidateIds = @DublicateCandidateIds + ',' + CONVERT(VARCHAR(20),@ReturnValue)<br />
<span style="white-space: pre;"> </span>--print 'IF:' + @DublicateCandidateIds<br />
<span style="white-space: pre;"> </span>END<br />
<span style="white-space: pre;"> </span>END<br />
<span style="white-space: pre;"> </span>ELSE<br />
<span style="white-space: pre;"> </span>BEGIN<br />
<span style="white-space: pre;"> </span>SET @CandidateId = CONVERT(BIGINT, @CandidateIds)<br />
<span style="white-space: pre;"> </span>SET @CandidateIds = NULL<br />
<span style="white-space: pre;"> </span>-- print @CandidateId<br />
<span style="white-space: pre;"> </span>EXEC Proc_ @CandidateId,@FK_CorporateId,@FK_ProgramId,@Interview_DateTime,@Interview_Venue,@Interview_Remarks,@intInvitationStatus,@ReturnValue OUTPUT<br />
<span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> </span>IF(@ReturnValue != 0 AND @ReturnValue != -1)<br />
<span style="white-space: pre;"> </span>BEGIN<br />
<span style="white-space: pre;"> </span>SET @DublicateCandidateIds = @DublicateCandidateIds + ',' + CONVERT(VARCHAR(20),@ReturnValue)<br />
<span style="white-space: pre;"> </span>--print 'ELSE:' + @DublicateCandidateIds<br />
<span style="white-space: pre;"> </span>END<br />
<span style="white-space: pre;"> </span>END<br />
END</div>
Rajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-20044700039806585172019-07-14T06:37:00.001-07:002019-07-14T06:37:21.385-07:00Procedure Parameter in where condition<div dir="ltr" style="text-align: left;" trbidi="on">
WHERE<span style="white-space: pre;"> </span>(IsInterviewed = 0 OR IsInterviewed is null) <br />
<span style="white-space: pre;"> </span>AND ISNULL([Corporate-ShortListStatusForInterview],0) IN (2,3) -- Consolidated Candidate<span style="white-space: pre;"> </span>AND ((@strDistrictIds IS NOT NULL AND FK_DistrictId IN (SELECT [ID] FROM dbo.SplitIDs(@strDistrictIds))) OR (@strDistrictIds IS NULL))<br />
<br />
AND(<br />
((LEN(@Keywords) > 0 AND CP.FirstName LIKE '%' + @Keywords + '%') OR (@Keywords IS NULL OR LEN(@Keywords) = 0))<br />
OR<span style="white-space: pre;"> </span>((LEN(@Keywords) > 0 AND CP.MiddleName LIKE '%' + @Keywords + '%') )<br />
)<br />
AND ((@ProgramId IS NOT NULL AND P.ProgramId = @ProgramId) OR (@ProgramId IS NULL))</div>
Rajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-17310135477260666682018-10-11T07:02:00.000-07:002018-10-11T07:08:23.355-07:00Getting error 405 (Method Not Allowed) while calling POST method of WEBAPI from Angular<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="background-color: white; border: 0px; box-sizing: inherit; clear: both; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; padding: 0px; vertical-align: baseline;">
Issue is due CORS, it should be enabled in WEBAPI project. The CORS enabling not works through WEB.config code, you need to enable CORS through backend.</div>
<div style="background-color: white; border: 0px; box-sizing: inherit; clear: both; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; padding: 0px; vertical-align: baseline;">
Note - remove all web.config CORS enabling code if its there in web.config i.e the below code</div>
<pre class="default prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; box-sizing: inherit; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow-wrap: normal; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;"><code style="border: 0px; box-sizing: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;"><span class="tag" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><httpprotocol></httpprotocol></span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="tag" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><customheaders></customheaders></span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="tag" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><add span=""><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="atn" style="border: 0px; box-sizing: inherit; color: #e64320; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">name</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="atv" style="border: 0px; box-sizing: inherit; color: #0f74bd; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"Access-Control-Allow-Origin"</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="atn" style="border: 0px; box-sizing: inherit; color: #e64320; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">value</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="atv" style="border: 0px; box-sizing: inherit; color: #0f74bd; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"*"</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="tag" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">/></span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="tag" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><add span=""><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="atn" style="border: 0px; box-sizing: inherit; color: #e64320; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">name</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="atv" style="border: 0px; box-sizing: inherit; color: #0f74bd; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"Access-Control-Allow-Headers"</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="atn" style="border: 0px; box-sizing: inherit; color: #e64320; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">value</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="atv" style="border: 0px; box-sizing: inherit; color: #0f74bd; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"Content-Type"</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="tag" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">/></span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="tag" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><add span=""><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="atn" style="border: 0px; box-sizing: inherit; color: #e64320; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">name</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="atv" style="border: 0px; box-sizing: inherit; color: #0f74bd; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"Access-Control-Allow-Methods"</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="atn" style="border: 0px; box-sizing: inherit; color: #e64320; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">value</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="atv" style="border: 0px; box-sizing: inherit; color: #0f74bd; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"GET, POST, PUT, DELETE, OPTIONS"</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="tag" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">/></span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="tag" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"></span></add></span></add></span></add></span></code></pre>
</div>
<span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="tag" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"></span><br />
<pre class="default prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; box-sizing: inherit; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow-wrap: normal; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;"><code style="border: 0px; box-sizing: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;"><span class="tag" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"><div style="background-color: white; border: 0px; box-sizing: inherit; clear: both; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; padding: 0px; vertical-align: baseline; white-space: normal;">
Steps 1. Install CORS package Install-Package Microsoft.AspNet.WebApi.Cors for WEBAPI project 2. In WebApiConfig.cs add this code</div>
<pre class="default prettyprint prettyprinted" style="border: 0px; box-sizing: inherit; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow-wrap: normal; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;"><code style="border: 0px; box-sizing: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;"><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">var</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> corsAttribute </span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">=</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="border: 0px; box-sizing: inherit; color: #101094; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">new</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">EnableCorsAttribute</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="str" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"*"</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="str" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"Origin, Content-Type, Accept"</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">,</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span><span class="str" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">"GET, PUT, POST, DELETE, OPTIONS"</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">);</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
config</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="typ" style="border: 0px; box-sizing: inherit; color: #2b91af; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">EnableCors</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">(</span><span class="pln" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">corsAttribute</span><span class="pun" style="border: 0px; box-sizing: inherit; color: #303336; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">);</span></code></pre>
<div style="background-color: white; border: 0px; box-sizing: inherit; clear: both; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; padding: 0px; vertical-align: baseline; white-space: normal;">
Done.</div>
</span></code></pre>
<pre class="default prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; box-sizing: inherit; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow-wrap: normal; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;"><code style="border: 0px; box-sizing: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;"><span class="tag" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span></code></pre>
<pre class="default prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; box-sizing: inherit; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow-wrap: normal; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;"><code style="border: 0px; box-sizing: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline; white-space: inherit;"><span class="tag" style="border: 0px; box-sizing: inherit; color: #7d2727; font-family: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;">
</span></code></pre>
</div>
Rajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-63786789488740499012015-10-02T10:31:00.004-07:002015-10-02T10:33:15.266-07:00JSON Maximum length problem with ASP.NET WebForm/MVC<div dir="ltr" style="text-align: left;" trbidi="on">
http://forums.asp.net/t/1962449.aspx?JSON+Maximum+length+problem+with+ASP+NET </div>
Rajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com2tag:blogger.com,1999:blog-4950764193608905305.post-84410281663479812022015-08-04T23:04:00.004-07:002015-08-04T23:04:59.872-07:00ASP.NET State Service for Windows 8<div dir="ltr" style="text-align: left;" trbidi="on">
ASP.NET State Service is not installed by default in Windows 8 and should not be installed on a “home” system.<br />
To enabled this navigate to Control Panel -> Programs
-> Programs and Features -> Turn Windows Features on or off.
Select “ASP.NET 4.5″<br />
<a href="http://i0.wp.com/spacetech.dk/wp-content/uploads/2012/09/aspnet.png"><img alt="" class="alignnone size-full wp-image-1047" height="375" src="http://i0.wp.com/spacetech.dk/wp-content/uploads/2012/09/aspnet.png?resize=429%2C375" title="aspnet" width="429" /></a><br />
Open Run (Win + R) and write “services.msc”<br />
<a href="http://i1.wp.com/spacetech.dk/wp-content/uploads/2012/09/aspnetservices.png"><img alt="" class="alignnone size-full wp-image-1048" height="344" src="http://i1.wp.com/spacetech.dk/wp-content/uploads/2012/09/aspnetservices.png?resize=605%2C344" title="aspnetservices" width="605" /></a><br />
Here right click on “ASP.NET State Service” and press start.</div>
Rajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-83844698421315100112013-09-13T06:21:00.005-07:002013-09-13T06:21:57.307-07:00sqlserver :delete duplicate records<div dir="ltr" style="text-align: left;" trbidi="on">
WITH CTE (COl1,Col2, DuplicateCount)
AS
(
SELECT COl1,Col2,
ROW_NUMBER() OVER(PARTITION BY COl1,Col2 ORDER BY Col1) AS DuplicateCount
FROM DuplicateRcordTable
)
DELETE
FROM CTE
WHERE DuplicateCount > 1
GO
</div>
Rajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-31820969579512833832013-08-08T03:15:00.004-07:002013-08-08T03:15:25.202-07:00Foreigh key dependencySELECT
K_Table = FK.TABLE_NAME,
FK_Column = CU.COLUMN_NAME,
PK_Table = PK.TABLE_NAME,
PK_Column = PT.COLUMN_NAME,
Constraint_Name = C.CONSTRAINT_NAME
FROM
INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS C
INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS FK
ON C.CONSTRAINT_NAME = FK.CONSTRAINT_NAME
INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS PK
ON C.UNIQUE_CONSTRAINT_NAME = PK.CONSTRAINT_NAME
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE CU
ON C.CONSTRAINT_NAME = CU.CONSTRAINT_NAME
INNER JOIN (
SELECT
i1.TABLE_NAME,
i2.COLUMN_NAME
FROM
INFORMATION_SCHEMA.TABLE_CONSTRAINTS i1
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE i2
ON i1.CONSTRAINT_NAME = i2.CONSTRAINT_NAME
WHERE
i1.CONSTRAINT_TYPE = 'PRIMARY KEY'
) PT
ON PT.TABLE_NAME = PK.TABLE_NAMERajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-68488150584352219232013-01-25T10:35:00.000-08:002013-01-25T10:35:05.084-08:00MVC:Entity Framework Exception “The underlying provider failed on Open” <div dir="ltr" style="text-align: left;" trbidi="on">
<br />
http://stack247.wordpress.com/2011/03/02/entity-framework-exception-the-underlying-provider-failed-on-open/
When trying to query data from Entity Framework, my code always return the following error:
The underlying provider failed on Open.
Turn out the problem was on the Connection String for the entity.
In the config file, we have to include “Password” parameter in “connectionString” attribute.
<connectionStrings>
<add name="SomeEntities" connectionString="metadata=res://*/Models.DB.csdl|res://*/Models.DB.ssdl|res://*/Models.DB.msl;provider=System.Data.SqlClient;provider connection string="Data Source=SERVER\INSTANCE;Initial Catalog=Database;User ID=username;Password=password;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
</connectionStrings>
it works now!
</div>
Rajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-80743580659758402412008-09-02T05:34:00.002-07:002012-02-20T23:05:55.267-08:00Genericeshttp://msdn.microsoft.com/en-us/library/512aeb7t(VS.80).aspx<br />http://www.c-sharpcorner.com/UploadFile/sdhar8po/GenericsInCSharp11152005055344AM/GenericsInCSharp.aspx<br />http://www.csharp-station.com/Tutorials/Lesson20.aspx<br />http://www.codeproject.com/Articles/8360/Generics-in-C-2-0Rajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-4763789599228989912012-02-14T23:09:00.001-08:002012-02-14T23:09:44.132-08:00differences between ERP and CRMhttp://trak.in/tags/business/2010/12/27/erp-vs-crm/<br />http://enterprisefeatures.com/2010/08/what%E2%80%99s-the-difference-between-crm-and-erp/Rajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-59177227848880661722012-02-11T10:15:00.001-08:002012-02-11T10:15:39.055-08:00Understanding Request Validation in ASP.NET MVC 3http://weblogs.asp.net/imranbaloch/archive/2011/02/19/understanding-request-validation-in-asp-net-mvc-3.aspxRajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-66689447192346544562012-02-11T09:55:00.000-08:002012-02-11T09:56:13.132-08:00difference char/varchar/nvarchar in sqlserverhttp://www.sql-server-helper.com/faq/data-types-p01.aspxRajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-85391731469393846452012-02-11T09:47:00.000-08:002012-02-11T09:48:10.449-08:00XML Output From SELECT Command in SQL Server 2005http://khanrahim.wordpress.com/2010/03/20/xml-output-from-select-command-in-sql-server-2005/Rajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-28567258931278586042012-02-11T09:34:00.000-08:002012-02-11T09:38:21.091-08:00Delete Duplicate Rows SQL SERVER – 2005 – 2008http://blog.sqlauthority.com/2009/06/23/sql-server-2005-2008-delete-duplicate-rows/<br /><br />we will delete duplicate rows using CTE and ROW_NUMBER() feature of SQL Server 2005 and SQL Server 2008.<br /><br />This method is improved over the earlier method as it not only uses CTE and ROW_NUMBER, but also demonstrates the power of CTE with DELETE statement. We will have a comprehensive discussion about it later in this article. For now, let us first create a sample table from which we will delete records.<br /><br />/* Create Table with 7 entries - 3 are duplicate entries */<br />CREATE TABLE DuplicateRcordTable (Col1 INT, Col2 INT)<br />INSERT INTO DuplicateRcordTable<br />SELECT 1, 1<br />UNION ALL<br />SELECT 1, 1 --duplicate<br />UNION ALL<br />SELECT 1, 1 --duplicate<br />UNION ALL<br />SELECT 1, 2<br />UNION ALL<br />SELECT 1, 2 --duplicate<br />UNION ALL<br />SELECT 1, 3<br />UNION ALL<br />SELECT 1, 4<br />GO<br /><br />The above table has total 7 records, out of which 3 are duplicate records. Once the duplicates are removed we will have only 4 records left.<br /><br />/* It should give you 7 rows */<br />SELECT *<br />FROM DuplicateRcordTable<br />GO<br /><br /><br />The most interesting part of this is yet to come. We will use CTE that will re-generate the same table with additional column, which is row number. In our case, we have Col1 and Col2 and both the columns qualify as duplicate rows. It may be a different set of rows for each different query like this. Another point to note here is that once CTE is created DELETE statement can be run on it. We will put a condition here – when we receive more than one rows of record, we will remove the row which is not the first one. When DELETE command is executed over CTE it in fact deletes from the base table used in CTE.<br /><br />/* Delete Duplicate records */<br />WITH CTE (COl1,Col2, DuplicateCount)<br />AS<br />(<br />SELECT COl1,Col2,<br />ROW_NUMBER() OVER(PARTITION BY COl1,Col2 ORDER BY Col1) AS DuplicateCount<br />FROM DuplicateRcordTable<br />)<br />DELETE<br />FROM CTE<br />WHERE DuplicateCount > 1<br />GO<br /><br />It is apparent that after delete command has been run, we will have only 4 records, which is almost the same result which we would have got with DISTINCT, with this resultset. If we had more than 2 columns and we had to run unique on only two columns, our distinct might have not worked here . In this case, we would have to use above the mentioned method.<br /><br />/* It should give you Distinct 4 records */<br />SELECT *<br />FROM DuplicateRcordTable<br />GO<br /><br /><br />This method is a breeze and we can use this for SQL Server version 2005 and the later versions.Rajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-84422011326830705692011-12-01T04:50:00.000-08:002011-12-01T04:52:55.616-08:00CTE recursivehttp://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/<br />----------------<br />SQL SERVER – Simple Example of Recursive CTE<br /><br />Recursive is the process in which the query executes itself. It is used to get results based on the output of base query. We can use CTE as Recursive CTE (Common Table Expression). You can read my previous articles about CTE by searching at http://search.SQLAuthority.com .<br /><br />Here, the result of CTE is repeatedly used to get the final resultset. The following example will explain in detail where I am using AdventureWorks database and try to find hierarchy of Managers and Employees.<br /><br />USE AdventureWorks<br />GO<br />WITH Emp_CTE AS (<br />SELECT EmployeeID, ContactID, LoginID, ManagerID, Title, BirthDate<br />FROM HumanResources.Employee<br />WHERE ManagerID IS NULL<br />UNION ALL<br />SELECT e.EmployeeID, e.ContactID, e.LoginID, e.ManagerID, e.Title, e.BirthDate<br />FROM HumanResources.Employee e<br />INNER JOIN Emp_CTE ecte ON ecte.EmployeeID = e.ManagerID<br />)<br />SELECT *<br />FROM Emp_CTE<br />GO<br /><br />In the above example Emp_CTE is a Common Expression Table, the base record for the CTE is derived by the first sql query before UNION ALL. The result of the query gives you the EmployeeID which don’t have ManagerID.<br /><br />Second query after UNION ALL is executed repeatedly to get results and it will continue until it returns no rows. For above e.g. Result will have EmployeeIDs which have ManagerID (ie, EmployeeID of the first result). This is obtained by joining CTE result with Employee table on columns EmployeeID of CTE with ManagerID of table Employee.<br /><br />This process is recursive and will continue till there is no ManagerID who doesn’t have EmployeeID.Rajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-14504796115833073202010-11-23T06:50:00.001-08:002010-11-28T10:13:53.987-08:00WCF1-http://www.c-sharpcorner.com/uploadfile/sunilbabuylv/wcf4beginners08132008040537am/wcf4beginners.aspx<br />2-http://www.wcftutorial.net/Home.aspxRajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-12262177057384573612010-11-23T06:54:00.001-08:002010-11-23T06:54:20.070-08:00WFhttp://ceres.napier.ac.uk/staff/bill/wwf.pdfRajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-53517374230750900362010-09-16T00:34:00.001-07:002010-09-16T00:34:53.221-07:00Header column Text in Datagridhttp://www.codeproject.com/KB/webforms/Datagrid_Col_Example.aspx<br />private void HideShowColumns(DataGrid dg)<br />{<br /> if(dg == null)<br /> {<br /> return;<br /> }<br /> // Loop through all of the columns in the grid.<br /><br /> foreach(DataGridColumn col in dg.Columns)<br /> {<br /> // Hide the Salary and SS# Columns.<br /><br /> if(col.HeaderText == "ExampleColumn")<br /> {<br /> col.Visible = false;<br /> }<br /> }<br />}Rajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-34637481890717170452009-05-26T05:42:00.001-07:002010-09-15T11:19:50.336-07:00Delegates Studyhttp://www.akadia.com/services/dotnet_delegates_and_events.html<br />http://www.c-sharpcorner.com/UploadFile/Ashush/Delegates02152008155757PM/Delegates.aspx<br />http://www.codersource.net/csharp_delegates_events.html<br />http://www.developerfusion.com/article/3057/events-and-delegates/<br />http://www.csharp-station.com/Tutorials/lesson14.aspxRajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-72301263785519349162010-09-13T04:32:00.000-07:002010-09-13T04:33:13.503-07:00interface with private methodhttp://msdn.microsoft.com/en-us/library/87d83y5b%28VS.80%29.aspx<br />http://msdn.microsoft.com/en-us/library/ms173157%28v=VS.80%29.aspxRajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-51522469138901645332010-09-02T08:51:00.001-07:002010-09-02T08:51:19.431-07:00parmshttp://msdn.microsoft.com/en-us/library/w5zay9db%28VS.71%29.aspxRajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-91937127587286779742010-09-02T08:08:00.000-07:002010-09-02T08:11:59.732-07:00call by value and referencehttp://msdn.microsoft.com/en-us/library/s6938f28%28VS.80%29.aspx<br /><br />http://msdn.microsoft.com/en-us/library/0f66670z%28VS.71%29.aspx#vclrfpassingmethodparameters_example1Rajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-25524614535986321052010-09-02T07:40:00.000-07:002010-09-02T07:41:07.455-07:00ref and out variabls differenceshttp://msdn.microsoft.com/en-us/library/t3c3bfhx%28VS.80%29.aspxRajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-23627746578393273992010-09-01T06:01:00.001-07:002010-09-01T06:01:45.191-07:00Access modifierhttp://www.codeproject.com/KB/cs/CsharpAccessModifiers.aspxRajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0tag:blogger.com,1999:blog-4950764193608905305.post-66220396624311480712010-08-31T05:43:00.001-07:002010-08-31T05:43:35.098-07:00Constructorhttp://www.codeproject.com/KB/dotnet/ConstructorsInCSharp.aspxRajat Goyelhttp://www.blogger.com/profile/04498884752726747926noreply@blogger.com0