Sunday, November 1, 2015

Compare two SQL Server Databases


--     Table Difference tool allows you to discover and reconcile differences between a source and destination table or a view. Tablediff Utility can report differences on schema and data. The most popular feature of tablediff is the fact that it can generate a script that you can run on the destination that will reconcile differences between the tables. TableDiff.exe takes 2 sets of input;
--     Connectivity - Provide source and destination objects and connectivity information. • Table Difference tool allows you to discover and reconcile differences between a source and destination table or a view. Tablediff Utility can report differences on schema and data. The most popular feature of tablediff is the fact that it can generate a script that you can run on the destination that will reconcile differences between the tables. dbcompare.exe takes 2 sets of input;
--     Connectivity - Provide source and destination objects and connectivity information. • Table Difference tool allows you to discover and reconcile differences between a source and destination table or a view. Tablediff Utility can report differences on schema and data. The most popular feature of tablediff is the fact that it can generate a script that you can run on the destination that will reconcile differences between the tables. dbcompare.exe takes 2 sets of input;
--Connectivity - Provide source and destination objects and connectivity information.

Db compare exe Download

Wednesday, October 21, 2015

LINQPad USE


LINQPad allows you to execute single LINQ commands against an existing EF model, or even to write dot net code in the editor and execute it like a little dynamic dot net environment.  The main application is free, but there is an auto-complete feature to the editor that you must pay in order to activate. Believe me it is worth it to pay for the license, you also support the author and show him the application is worthMONEY .  The license is very inexpensive and well worth the price in order to get intellisense like behavior on your LINQ queries.
The first couple versions I played with worked great with SQL Server, but could not load the VistaDB EF provider.  I was bummed, but at least I could debug my queries against SQL Server, and then run against VistaDB to make sure it worked the same way.  But I recently got an email from the author of LINQPad that it could load VistaDB, in version 2.


Monday, October 19, 2015

Email Templates

Sample
Main program
static void Main(string[] args)
        {
            new Email().Run();
        }


Cs.file

public class Email
    {
       public void Run()
       {
           try
           {
               System.Net.Mail.MailMessage newmsg = new System.Net.Mail.MailMessage();

               newmsg.From = new MailAddress("from address full");

               newmsg.Subject = "Testing2";
               newmsg.To.Add("to address");
               //newmsg.To.Add("choulla.naresh@gmail.com");
               newmsg.Body = "Hellooooo2";
               SmtpClient smtp = new SmtpClient();
               smtp.Host = "host address";
//port number
               smtp.Port = "port number";
               smtp.Credentials = new System.Net.NetworkCredential("username",                      "password");
               //smtp.UseDefaultCredentials = false;
               smtp.EnableSsl = false;
               smtp.Send(newmsg);
           }
           catch(Exception Ex)
           {
               //smtp.Send(msg);
           }
       }

    }

Tuesday, October 6, 2015

Read Xml data and display Jquary

<?xml version="1.0" encoding="utf-8" ?>
        <booklist>
            <book>
                <title>Naresh</title>
                <author>Naresh1</author>
                <genre>Classic</genre>
            </book>
            <book>
                <title>abc</title>
                <author>def</author>
                <genre>Classic</genre>
            </book>
            <book>
                <title>qqq</title>
                <author>asd</author>
                <genre>www</genre>
            </book>
          
        </booklist>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
        <script>
            $(document).ready(function () {
                $("#contentArea").append("<ul></ul>");
                $.ajax({
                    type: "GET",
                    url: "data.xml",
                    dataType: "xml",
                    success: function (xml) {
                        $(xml).find('Book').each(function () {
                            var sTitle = $(this).find('Title').text();
                            var sAuthor = $(this).find('Author').text();
                            var sGenre = $(this).find('Genre').text();
                            $("<li></li>").html(sTitle + ", " + sAuthor + "," + sGenre).appendTo("#contentArea ul");
                        });
                    },
                    error: function () {
                        alert("An unexpected error has occurred during processing.");
                    }
                });
            });
        </script>

     
        <div id="contentArea">

        </div>

Validate Listbox Ckeckbox Abd Radio Buttons

<asp:ListBox ID="ListBox1" runat="server" Rows="6" SelectionMode="Multiple">
            <asp:listitem text="India" value="1"></asp:listitem>
            <asp:listitem text="US" value="2"></asp:listitem>
            <asp:listitem text="UK" value="3"></asp:listitem>
            <asp:listitem text="China" value="4"></asp:listitem>
            <asp:listitem text="Russia" value="5"></asp:listitem>
            <asp:listitem text="New Zealand" value="6"></asp:listitem>
        </asp:ListBox>
        <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Required two country" ClientValidationFunction="Validate_ListBox"></asp:CustomValidator>
        <asp:Button ID="btnSubmit" runat="server" Text="Submit" /><asp:ListBox ID="ListBox1" runat="server" Rows="6" SelectionMode="Multiple">
            <asp:listitem text="India" value="1"></asp:listitem>
            <asp:listitem text="US" value="2"></asp:listitem>
            <asp:listitem text="UK" value="3"></asp:listitem>
            <asp:listitem text="China" value="4"></asp:listitem>
            <asp:listitem text="Russia" value="5"></asp:listitem>
            <asp:listitem text="New Zealand" value="6"></asp:listitem>
        </asp:ListBox>
        <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Required two country" ClientValidationFunction="Validate_ListBox"></asp:CustomValidator>
        <asp:Button ID="btnSubmit" runat="server" Text="Submit" />
        <script>
            function Validate_ListBox(sender, args) {
                var Listoptions = document.getElementById("<%=ListBox1.ClientID%>").options;
                var Selectedcount = 0;
                for (var i = 0; i < Listoptions.length; i++) {
                    if (Listoptions[i].selected == true) {
                        Selectedcount++;
                    }
                }
                if (Selectedcount <= 2) {
                    args.IsValid = false;
                } else {
                    args.IsValid = true;
                }
            }
        </script>


        /////////////////////////////////////////////
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
        <script>
            function CheckBoxList1_Validation(sender, args) {
                args.IsValid = false;
                var cnt = $("#CheckBoxList1 input:checked").length;
                args.IsValid = (cnt >= 2);
            }
        </script>
        Select at least 2 countries:
        <asp:CheckBoxList ID="CheckBoxList1" runat="server">
            <asp:listitem text="India" value="1"></asp:listitem>
            <asp:listitem text="US" value="2"></asp:listitem>
            <asp:listitem text="UK" value="3"></asp:listitem>
            <asp:listitem text="China" value="4"></asp:listitem>
            <asp:listitem text="Russia" value="5"></asp:listitem>
            <asp:listitem text="New Zealand" value="6"></asp:listitem>
        </asp:CheckBoxList>
        <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Please select at least 2 countries" ClientValidationFunction="CheckBoxList1_Validation" ForeColor="Red"></asp:CustomValidator>
        <asp:Button ID="btnSubmit" runat="server" Text="Submit" />


        ///////////////////////////////////////////////////////
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
        <script>
            function RadioButtonList1_Validate(sender, args) {
                args.IsValid = ($("#RadioButtonList1 :radio:checked").length > 0);
            }
        </script>
        <asp:RadioButtonList ID="RadioButtonList1" runat="server">
           <asp:listitem text="India" value="1"></asp:listitem>
            <asp:listitem text="US" value="2"></asp:listitem>
            <asp:listitem text="UK" value="3"></asp:listitem>
            <asp:listitem text="China" value="4"></asp:listitem>
            <asp:listitem text="Russia" value="5"></asp:listitem>
            <asp:listitem text="New Zealand" value="6"></asp:listitem>
        </asp:RadioButtonList>
        <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Please select a country" Display="Dynamic" ClientValidationFunction="RadioButtonList1_Validate" ForeColor="Red"></asp:CustomValidator>
        <br />

        <asp:Button ID="btnSubmit" runat="server" Text="Submit" />