Monday, 26 January 2015

warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] in COBOL

I recently installed Open-COBOL in Ubuntu. I wrote a program helloworld.cbl and compiled it using command:

cobc -free -x -o helloworld helloworld.cbl

After compiling the code, I got a bunch of warnings all of which looks like:

warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

Solution:
To get rid of the warnings, compile the code using command:
     cobc -free -x -O -o helloworld helloworld.cbl


Wednesday, 21 January 2015

Error: syntax error, unexpected "end of file" in COBOL


Key Point:
Each line should end with CRLF (Carriage Return + Line Feed). It means each line should end with '\r\n'.

Solution:
To get rid of the error, copy-paste the code in Notepad++ and do the following steps:

1) Replace '\n' with '' (blank).
2) Replace '\r' with '\r\n'
3) Go to the last line and hit Enter.

Tuesday, 13 January 2015

Select Default Option in DropDownList on PageLoad in ASP.Net using jQuery

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="DemoGrid.Default" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script src="Scripts/jquery-1.11.2.min.js"></script>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <script type="text/javascript">
            $(document).ready(function () {
                $("select#DropDownList1 option").filter(function () {
                    return $(this).val() == "0";
                }).prop('selected', true);
            });
        </script>

        <div>
            <asp:DropDownList ID="DropDownList1" runat="server">
                <asp:ListItem Value="0">Select</asp:ListItem>
            </asp:DropDownList>
            <asp:Button runat="server" Text="dummy" />
        </div>
    </form>
</body>
</html>


Clear Multiple Textboxes in ASP.Net on Button Click


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="DemoGrid.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <script type="text/javascript">
            function Clear() {
                var txts = document.getElementsByClassName('txts');

                for (var i = 0; i < txts.length; i++)
                    txts[i].value = '';

                return false;
            }
        </script>

        <div>
            <asp:TextBox ID="txt1" runat="server" CssClass="txts"></asp:TextBox>
            <asp:TextBox ID="txt2" runat="server" CssClass="txts"></asp:TextBox>
            <asp:TextBox ID="txt3" runat="server" CssClass="txts"></asp:TextBox>
            <asp:TextBox ID="txt4" runat="server" CssClass="txts"></asp:TextBox>

            <input type="button" name="name" value=" Clear" onclick="Clear();" />
        </div>
    </form>
</body>
</html>


Enable-Disable a Panel using Javascript in ASP.NET

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="DemoGrid.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <script type="text/javascript">
            function Enable() {
                var controls = document.getElementById("<%=mypanel.ClientID%>").getElementsByTagName("input");

                for (var i = 0; i < controls.length; i++) {
                    controls[i].disabled = false;
                }
            }

            function Disable() {
                var controls = document.getElementById("<%=mypanel.ClientID%>").getElementsByTagName("input");

                for (var i = 0; i < controls.length; i++) {
                        controls[i].disabled = true;
                }
            }
        </script>
            <asp:Panel ID="mypanel" runat="server">
                <asp:TextBox runat="server" />
                <asp:TextBox runat="server" />
                <asp:CheckBox Text="text" runat="server" />
                <asp:Button runat="server" Text="Dummy" />
            </asp:Panel>
            <input type="button" name="name" value=" Disable" onclick="Disable();" />
            <input type="button" name="name" value=" Enable" onclick="Enable();" />
    </form>
</body>
</html>

Monday, 5 January 2015

Cannot login to Sql Server using Windows Authentication


I had the same problem. When I tried to login the Sql Server with Windows Authentication, following error message was displayed :