Thursday, March 7, 2013

Read Data from CSV file and Populate to Dataset



A Function to read CSV file data and populate the data into dataset.

strFolderPath==The path of Source Folder.

strFileName==The Path of the Source File.





Public Function GetCsvData(ByVal strFolderPath As String, ByVal strFileName As String) As DataTable
 
        Dim strConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFolderPath & ";Extended Properties=Text;"
        Dim conn As New OleDbConnection(strConnString)
 
        Try
            conn.Open()
            Dim cmd As New OleDbCommand("SELECT * FROM [" & strFileName & "]", conn)
            Dim da As New OleDbDataAdapter()
 
            da.SelectCommand = cmd
 
            Dim ds As New DataSet()

            da.Fill(ds)
            da.Dispose()

            Return ds.Tables(0)
        Catch
            Return Nothing
        Finally
            conn.Close()
        End Try
 
 End Function


10 Self Improvement Activities


These self improvement activities will help you become more productive, get into the positive state of mind and achieve better quality of life.

In this article you will also find out how to use your energy effectively, what is the quickest way to achieve personal growth and how to excel in every activity.


1.Use your energy on important things

If you want to succeed in life, you should not waste your energy on activities that do not bring any benefits.

Such useless activities include surfing the Internet without any purpose, watching TV, worrying and wasting money.

When you are involved in such activities, you have no or little energy left for activities that can create a better future. It is worth prioritising and accomplishing important tasks first, and then if you still have enough energy, you may decide to do the unimportant.



2.Focus on one task at a time

If you want to get perfect results, you should only concentrate on one activity. This way all your energy will go into it and you will accomplish it perfectly.

If you waste your energy on several things at the same time, you will get average results because you will divide your energy between the activities.



3.Control your thinking

To avoid chaos in your mind resulting in chaos in the outside world, you should try to observe your thoughts. Once you start doing that, you will notice how many negative thoughts you get daily.

By observing negative thinking you will be able to emotionally disengage from it. As a result, negative thinking will affect you less and you will notice that your days are getting more peaceful and positive.


4.Get organised

When you live in an organised manner, you do not suffer from stress and your life is peaceful and balanced.

To start living this way, you should start planning your day in advance. This will eliminate any stress caused by being late to a meeting or forgetting to complete some task.

You should also live in tidiness because by keeping your home clean you also keep your mental state clear and peaceful. Such mental state will benefit you in many ways, including improved memory and less negativity.


5.Live in the present

Although this self improvement activity may seem strange to you, it is a very important activity that many ignore. The majority of people do not live in the present. They either dwell on their past or daydream about the future. They seem to forget the most important time of all - the present.

You should enjoy every present moment because your current state of mind always manifests in the outside world, creating your future accordingly.

Therefore if your main mood is very positive, you will experience only happy days. However, if you dwell on negative thoughts, you are sure to encounter many obstacles and misfortunes in the present and days to come.



6.Complete each task in a perfect manner

Whenever you are working on some project, try to accomplish it in the best way possible. Always ask yourself 'Is this project turned out as perfect as it could possibly be?' If the answer is no, try to correct or add something to it until there is nothing that you can improve.

This way you will make sure that each single task you accomplish is done in an excellent manner. By doing this you will create successful future because you cannot possibly fail if you only get perfect results.

Also, when you entirely focus on one task excluding everything else, you will notice that you start enjoying the task. If you concentrate on the task but still do not enjoy it, that means that you probably see the task as a means to an end rather than the process.

You should start focusing on the process itself to find enjoyment in the task. Such enjoyment will fuel motivation and you will accomplish everything quicker and better.

If you enjoy your work, you will put only positive energy into it. As a result, your completed tasks will bring you success.



7.Challenge yourself

Nothing develops you more than challenges. Challenges force you to shift your comfort zone, experience new situations and make you grow. Without challenges life would be very boring and depressing.

Challenges are necessary for every human being who is seeking quality life. Only through trial and error you realise who you really are, which activities you like and what preferences you have.

You can easily measure the success of a person by the amount of challenges s/he had.



8.Read personal development books

There is nothing more important than searching information about self improvement. Without reading any self improvement books or articles you cannot improve yourself.



9.Socialize only with positive people

Positive people can inspire, empower and make you happy. It is so much worth to be at least once in a while with positive people rather than constantly spend time with negative friends or relatives.

If you spend your days with, for example, lazy people, you may notice that you are becoming lazy.

If all your friends' main qualities are negative, try to avoid all of them. This way you will not be affected in a negative way and after some time will start attracting positive people.



10.Exercise

Daily exercise develops determination, focus and patience. It improves your health and strengthens your body. It makes you more active, positive and invincible.

People who exercise every day are always perceived as strong-willed and disciplined.


Conclusion

These personal improvement activities are sure to put you on the track to success. I hope that you will apply the steps in this article and, as a result, will greatly improve the quality of your life. Hope you found this article useful.

Wednesday, March 6, 2013

SQL Queries to analyse database


Query to show Table_name, No_Of_Rows,No_of_col,dataSize

USE bone
GO
CREATE TABLE #temp (
table_name sysname ,
row_count INT,
reserved_size VARCHAR(50),
data_size VARCHAR(50),
index_size VARCHAR(50),
unused_size VARCHAR(50))
SET NOCOUNT ON
INSERT #temp
EXEC sp_msforeachtable 'sp_spaceused ''?'''
SELECT a.table_name,
a.row_count,
COUNT(*) AS col_count,
a.data_size
FROM #temp a
INNER JOIN information_schema.columns b
ON a.table_name collate database_default
= b.table_name collate database_default
GROUP BY a.table_name, a.row_count, a.data_size
ORDER BY CAST(REPLACE(a.data_size, ' KB', '') AS integer) DESC
DROP TABLE #temp


bone is database name here.


Query to show DataBase Name, Database Size,Unallocated_Space

EXEC sp_spaceused




























Query to show TableName, Rows,reserved,Data,Index_size,unused


EXEC sp_spaceused 'B1_AIRTEL_ATLTRANS'

B1_AIRTEL_ATLTRANS= <Table name>


































Chat With Command Prompt


NETWORKING HACK

Chat With Command Prompt
Talk with other computers on your network.

If you want a private chat with a friend or client on you Network, you don't need to download any fancy program!
All you need is your friends IP address and Command Prompt.
First, open Notepad and enter:

@echo off

echo Messenger

echo When typing the computer name, type

echo in /server:computer replacing

echo computer with the IP adress of the computer.

:START

set /p c=Enter computer name here:

:A

set /p m=Enter message here:

msg * %c% %m%

GoTo A



Now save this as "Messenger.bat". Open the .bat file and in Command Prompt you should see:
MESSENGER
User:
After "User" type the IP address of the computer you want to contact.
After this, you should see this:
Message:
Now type in the message you wish to send.
Before you press "Enter" it should look like this:
MESSENGER
User: 56.108.104.107
Message: Hi
Now all you need to do is press "Enter", and start chatting!

GPS geolocation in HTML5


<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Geolocation.aspx.vb" Inherits="HTML5Applications.Geolocation" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
  
    <!-- These ApI link used for Google
    <script src="http://code.google.com/apis/gears/gears_init.js" type="text/javascript"></script>
    <script src="geo.js" type="text/javascript" ></script>
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>-->
     <script type="text/javascript">
        function ShowMyLocation()
        {
            navigator.geolocation.getCurrentPosition(locationSuccess, locationFail);
        }
       
        function locationSuccess(position)
        {
            latitude = position.coords.latitude;
            longitude = position.coords.longitude;
        }
       
        function locationFail()
        {
            alert("Oops, could not find you.");
        }

        var map = null;
        function GetMap()
        {

          
            /* Replace YOUR_BING_MAPS_KEY with your own credentials.
            Obtain a key by signing up for a developer account at
            http://www.microsoft.com/maps/developers/ */
            /*my key is AumaKlvNi3BaMXMaE1PmXwa7jpAu29Ot3oQrbpU33wUcVh2k0b2T05Kxu7eVuY9I */
            var cred = "AumaKlvNi3BaMXMaE1PmXwa7jpAu29Ot3oQrbpU33wUcVh2k0b2T05Kxu7eVuY9I";
            // Initialize map
            map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),{ credentials: cred });
            // Check if browser supports geolocation
            if (navigator.geolocation)
            {
                navigator.geolocation.getCurrentPosition(locateSuccess, locateFail);
            }
            else
            {
                alert('I\'m sorry, but Geolocation is not supported in your current browser. Have you tried running this demo in IE9?');

            }

        }

        // Successful geolocation
        function locateSuccess(loc)
        {
            // Set the user's location
            var userLocation = new Microsoft.Maps.Location(loc.coords.latitude, loc.coords.longitude);
            // Zoom in on user's location on map
            map.setView({ center: userLocation, zoom: 17 });
            // Draw circle of area where user is located
            var locationArea = drawCircle(userLocation);
            map.entities.push(locationArea);

        }

        // Unsuccessful geolocation
        function locateFail(geoPositionError)
        {
            switch (geoPositionError.code)
            {
                case 0: // UNKNOWN_ERROR.
                    alert('An unknown error occurred, sorry');
                    break;
                case 1: // PERMISSION_DENIED55.
                    alert('Permission to use Geolocation was denied');
                    break;
                case 2: // POSITION_UNAVAILABLE
                    alert('Couldn\'t find you...');
                    break;
                case 3: // TIMEOUT
                    alert('The Geolocation request took too long and timed out');
                    break;
                default:

            }

        }

        // Draw blue circle on top of user's location
        function drawCircle(loc)
        {
            var radius = 100;
            var R = 6378137;
            var lat = (loc.latitude * Math.PI) / 180;
            var lon = (loc.longitude * Math.PI) / 180;
            var d = parseFloat(radius) / R;
            var locs = new Array();
            for (x = 0; x <= 360; x++)
            {
                var p = new Microsoft.Maps.Location();
                brng = x * Math.PI / 180;
                p.latitude = Math.asin(Math.sin(lat) * Math.cos(d) + Math.cos(lat) * Math.sin(d) * Math.cos(brng));
                p.longitude = ((lon + Math.atan2(Math.sin(brng) * Math.sin(d) * Math.cos(lat), Math.cos(d) - Math.sin(lat) * Math.sin(p.latitude))) * 180) / Math.PI;
                p.latitude = (p.latitude * 180) / Math.PI;
                locs.push(p);
            }
            return new Microsoft.Maps.Polygon(locs, { fillColor: new Microsoft.Maps.Color(125, 0, 0, 255), strokeColor: new Microsoft.Maps.Color(0, 0, 0, 255) });

        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
         <div style="background-color: lightgoldenrodyellow; text-align: left;">
    <H2>CHECK YOUR GEOLOCATION</H2>
             </div>
        <br /><br />
        <input type="button" id="btnShowLocation" name="btnShowLocation" value="Show my Location" onclick="GetMap();" />
        <br /><br />
        <div id="mapDiv" style="position: relative; width: 800px; height: 600px;"></div>
         </div>
        <br /><br />
         <div style="background-color: GrayText; text-align: center;">
          &nbsp;
        </div>
    </form>
</body>
</html>