Monday 31 December 2018

Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AI" in the equal to operation.

//////////////


select * from [DBName].[dbo].[tableName_1] t inner join [DBName].[dbo].[tableName_2]  b on a.ColumnName COLLATE DATABASE_DEFAULT =b.ColumnName COLLATE DATABASE_DEFAULT

Friday 28 December 2018

The test form is only available for requests from the local machine.

////////////////////

<configuration>
    <system.web>
    <webServices>
        <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
        </protocols>
    </webServices>
    </system.web>
</configuration>

Thursday 20 December 2018

Run time progress bar client side using jquery

//////////////////////////// HTML
    <script src="https://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="https://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>

    <link href="https://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css">

<style>
        progress
        {
            -webkit-appearance: progress-bar;
            background-color: red;
            box-sizing: border-box;
            display: inline-block;
            height: 30px;
            width: 100%;
            vertical-align: -0.25em;
        }
        .progressbar
        {
            border: 1px solid #aaaaaa;
            height: 40px;
            background: #f38282;
        }
        .ui-widget-header
        {
            border: 1px solid #aaaaaa;
            background: #70c370 !important;
        }
        .ui-widget-content
        {
            border: 1px solid #aaaaaa;
            background: #f38282 !important;
        }

    </style>


    <input class="valIn" value="1" onkeyup="abc(event)" />
    <br>
    <br>
    <div class="progressbar">
    </div>
    <br />   
    <br>

    <span class="set">0</span> <span class="lessset">0</span>



//////////////// JQuery
<script type="text/javascript">
        var x = 0;
        function abc(e) {
            if ((e.keyCode > 47 && e.keyCode < 57) || (e.keyCode == 8 || e.keyCode == 46)) {
                var xvv = 500;
                var x = parseInt($(".valIn").val());
                var pr = (x * 100 / xvv)
                $(".progressbar").progressbar({
                    value: pr
                });
                $(".set").text("Percentage : "+pr + "%");
                var xt = (xvv - parseInt(x));
                $(".lessset").text("Total in (500) : "+xt);
                if (x == xvv) {
                    $(".lessset").text("Complete");
                    $(".lessset").css({ "background-color": "green", "color": "#fff" });
                }
                else {
                    $(".lessset").css("background-color", "red");
                }
            }
        }



    </script>

Result////////////////////////


                                   









         

Tuesday 18 December 2018

Window service in .net c# with Timer

///////////////// Code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using System.Configuration;
namespace SendMailTimer
{
    public partial class SendMails : ServiceBase
    {
        Timer _tmr;
        static bool timerVal = true;

        public SendMails()
        {
            InitializeComponent();
            _tmr = new Timer(new TimerCallback(Tmr_TickEvent), null, Timeout.Infinite, Timeout.Infinite);
            _tmr.Change(0, 60000);// 1min. = 60000 = 60 sec.
        }
        protected override void OnStart(string[] args)
        {
            Common.WriteToFile("Service Started");
        }
        protected override void OnStop()
        {
            _tmr.Dispose();
            Common.WriteToFile("Service Stopped");
        }

        public void Tmr_TickEvent(object state)
        {
            if (timerVal == true)
            {
                timerVal = false;
                try
                {
                 
                    timerVal = true;
                }
                catch (Exception _ex)
                {
                    Common.WriteToFile(DateTime.Now + "::.......................................Error.......................................");
                    timerVal = true;
                }
            }
        }
    }
}



////////////////////////   Steps

1.    Create new project >  windows service
2.    Change service name
3.    Double click on service
4.    Right click on service design >>  Add installer
5.    Right click on ServiceInstaller1 >> property >> Change Description , DisplayName                            and  ServiceName
6.    Right click on serviceProcessInstaller1 >> property >> Account >> Select LocalSystem

Copy above code and past and debug













Reduced or SHRINK .ldf file of the sql database

////////////////////

DBCC SHRINKFILE (N'.ldf file logincal Name' , 1)


DBCC SHRINKFILE (N'Test_log' , 1)

Steps : 
1.     Select your database
2.     Right click and go to property of the databases
3.     select tab files
4.     Check your database .ldf file name (Scroll right and check last column)
5.     Copy ldf file from column Logical Name and Execute. 






Friday 14 December 2018

Code to read xlsx sheet into a table in a SQL Server database

////////////////


Error-
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', search for 'Ad Hoc Distributed Queries' in SQL Server Books Online.


////////////Solution



EXEC sp_configure 'show advanced options', 1
RECONFIGURE
GO
EXEC sp_configure 'ad hoc distributed queries', 1
RECONFIGURE
GO


Monday 3 December 2018

Login failed for user 'NT AUTHORITY\SYSTEM' at iis or local sytem

//////////////////////// Error

Login failed for user 'NT AUTHORITY\SYSTEM'

//////////////////////// Solution

Set the pool identity on LocalSystem and thought why it might be preventing "NT AUTHRITY\SYSTEM" from opening a connection to my database. Opened up SQL Server Management Studio as the user "Administrator" and checked out the Server Roles for NT AUTHORITY\SYSTEM under "logins" section. The default server role for this user was public by default. So checked sysadmin also  and refreshed the web application form


Setp 1.  Select Your Database
Setp 2. Expand Security tab
Setp 3. Expand Logins
Setp 4. Go On NT AUTHORITY\SYSTEM
Setp 5. Right click and go to properties
Setp 6. Select Sysadmin also if not selected
Setp 7. Save and exit.






Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...