Tuesday, 27 January 2015

Select Dependencies SP in sql

select OBJECT_NAME(referencing_id) from sys.sql_expression_dependencies
where referenced_entity_name='tblSiteUsers'

Monday, 12 January 2015

File upload less then 4MB

if (fuDocumentFile.PostedFile.ContentLength > 2097152)
            {
                ShowMessage("File cannot upload more than 4MB.", "E");
                return;
            }

set default database in Sql Server

Steps: 1) Open Sql Server Management Studio
 2) Go to object Explorer -> Security -> Logins
 3) Right click on the login and select properties
 4) And in the properties window change the default database and click OK.

Friday, 9 January 2015

Determine if page is valid in JavaScript - ASP.NET

If I have a page that is using a bunch of ASP.NET validation controls I will use code similar to the following to validate the page. Make the call on an input submit. Hopefully this code sample will get you started!
    <input type="submit" value="Submit" onclick"ValidatePage();" />

    <script type="text/javascript">

    function ValidatePage() {

        if (typeof (Page_ClientValidate) == 'function') {
            Page_ClientValidate();
        }

        if (Page_IsValid) {
            // do something
            alert('Page is valid!');                
        }
        else {
            // do something else
            alert('Page is not valid!');
        }
    }

</script>

Wednesday, 7 January 2015

select [ernetNew].dbo.[tblInstituteDetailAndMain].[DomainName]
CLIENTDOMAINNAME
,
[dbo].[CLIENTREGISTRATION].[DOMAINSTATUS]
,[ernetNew].dbo.[tblInstituteDetailAndMain].[DomainStatus]
from [ernetNew].dbo.[tblInstituteDetailAndMain]
left join [dbo].[CLIENTREGISTRATION] on ltrim(rtrim([dbo].[CLIENTREGISTRATION].CLIENTDOMAINNAME))=rtrim(ltrim([ernetNew].dbo.[tblInstituteDetailAndMain].[DomainName]))

where [dbo].[CLIENTREGISTRATION].[DOMAINSTATUS]='DE'

Tuesday, 6 January 2015

In your case you don't need to nest multiple CASE expressions

In your case you don't need to nest multiple CASE expressions.
SELECT AccessTabF1.Month, AccessTabF1.Year, AccessTabF1.[Entity Number], 
case when [Exp Year] = 2010 + 1 -- why not = 2011 ?
     then 'Expires in 1 to 5 Years' -- this does not match the logic on line above
     when [Exp Year] > 2010 + 5 -- why not > 2015 ?
     then 'Expires After 5 Years'
     else 'No Expiration Year Listed' 
end
from AccessTabF1

Saturday, 3 January 2015

Check pdf using C# Code

public bool IsPDFHeader(string fileName)
    {
        byte[] buffer = null;
        FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
        BinaryReader br = new BinaryReader(fs);
        long numBytes = new FileInfo(fileName).Length;
        //buffer = br.ReadBytes((int)numBytes);
        buffer = br.ReadBytes(5);

        var enc = new ASCIIEncoding();
        var header = enc.GetString(buffer);

        //%PDF−1.0
        // If you are loading it into a long, this is (0x04034b50).
        if (buffer[0] == 0x25 && buffer[1] == 0x50
            && buffer[2] == 0x44 && buffer[3] == 0x46)
        {
            return header.StartsWith("%PDF-");
        }
        return false;

    }

Re: What is the MAX file upload size limit in ASP.net 4.0?

Re: What is the MAX file upload size limit in ASP.net 4.0?

Jul 12, 2013 08:16 PM|LINK
You likely will need to update your maxRequestLength within your web.config to handle files and uploads that are large (as the default limit is often 4MB).
It's important to know that maxAllowedContentLength is measured in bytes and maximumRequestLength is measured in kilobytes when settings these values so you'll need to adjust them accordingly if you plan on handling much larger files : 
<configuration>
    <system.web>
        <!-- This will handle requests up to 1024MB (1GB) -->
        <httpRuntime maxRequestLength="1048576" timeout="3600" />
    </system.web>
</configuration>

<!-- IIS Specific Targeting (noted by the system.webServer section) -->
<system.webServer>
   <security>
      <requestFiltering>
         <!-- This will handle requests up to 1024MB (1GB) -->
         <requestLimits maxAllowedContentLength="1048576000" />
      </requestFiltering>
   </security>
 </system.webServer>
Updating the maxRequestLength property is likely going to be the easiest method of handling this, however there are alternatives such as libraries like NeatUpload, which are designed to handle large files and can handle uploading files as streams to your preferred method of storage.
Jon Galloway covers handling large file uploads and several methods of handling them within .NET in this blog post, which would likely be an excellent read related to your topic.



If you are using IIS for hosting your application, then the default upload file size if 4MB. To increase it, please use this below section in your web.config -
<configuration>
    <system.web>
        <httpRuntime maxRequestLength="1048576" />
    </system.web>
</configuration>
For IIS7 and above, you also need to add the lines below:
 <system.webServer>
   <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
   </security>
 </system.webServer>
Note: maxAllowedContentLength is measured in bytes while maxRequestLength is measured in kilobytes, which is why the values differ in this config example. (Both are equivalent to 1 GB.)

Thursday, 1 January 2015

select report using continue dates

[dbo].[getAllDaysBetweenTwoDate]    Script Date: 01/02/2015 09:24:40 /
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[getAllDaysBetweenTwoDate]
(
@FromDate DATETIME='06/20/2014',   
@ToDate DATETIME='06/23/2014'
)
AS
BEGIN
   
    DECLARE @TOTALCount INT
    SET @FromDate = DATEADD(DAY,-1,@FromDate)
    Select  @TOTALCount= DATEDIFF(DD,@FromDate,@ToDate);
  

    WITH d AS
            (
              SELECT top (@TOTALCount) AllDays = DATEADD(DAY, ROW_NUMBER()
                OVER (ORDER BY object_id), REPLACE(@FromDate,'/',''))
              FROM sys.all_objects
            )
      
          (
         
         
        SELECT convert(varchar(30),AllDays,101) as MsgDate,
        (SELECT COUNT(*) AS MSG FROM JAN_TBL_NOTE_TASK SUB WHERE convert(varchar(30),SUB.Submit_Date,101)=convert(varchar(30),AllDays,101)) AS Replyonmsg,
        (SELECT COUNT(*) AS REPLY FROM JAN_TASK_TBL_MAIN_TASK SUB WHERE convert(varchar(30),SUB.Task_Create_Date,101)=convert(varchar(30),AllDays,101)) AS Totalmsg
         From d
          )
    RETURN
   
END