Navi's

Necessity, the mother of invention

  • Twitts

    Error: Twitter did not respond. Please wait a few minutes and refresh this page.

  • RSS My Reader

    • An error has occurred; the feed is probably down. Try again later.
  • Top Clicks

  • Advertisements
  • Visitor Map

    Locations of Site Visitors
  • Flag Counter

    free counters

Repair Network using .bat file

Posted by Navi's on January 14, 2011

In LAN, some times got network error (TCP/IP error 26) while accessing the SQL server. To resolve this error we have to repair our network connection using Right Click on network icon -> Repair.

While using Repair Option sometimes the repair option not work and repair dialog still appear. To resolve that problem I created the .bat script to repair LAN without using Repair Option.

Here is the Repair script

arp -d *

nbtstat -R

ipconfig /flushdns

nbttstat -RR

ipconfig /registerdns

Open notepad and copy/past above script and save it as .bat extention.

Thats it.. 🙂

Advertisements

Posted in Uncategorized | Leave a Comment »

Datatable to Generic collection and vice versa

Posted by Navi's on January 13, 2011

Most of the time we need to convert Generic Collection(GC) to DataTable(DT) and Data Table(DT) to Generic Collection(GC). For that bellow two functions are very helpfull to Convert Generic Function(GC) to DataTable(DT) and vice versa.

To convert DataTable(DT) to Generic Collection(GC) you can use bellow code snippet

Pass the DataTable(DT) object to bellow function and it will return you the Generic Collection(GC) of given type.

 public static List<T> ConvertTo<T>(DataTable table)
        {
            List<T> list = new List<T>();
            if (table == null)
            {
                return null;
            }

            List<DataRow> rows = new List<DataRow>();

            foreach (DataRow row in table.Rows)
            {
                T item = CreateItem<T>(row);
                list.Add(item);
            }

            return list;
        }
 public static T CreateItem<T>(DataRow row)
        {
            Type objType = typeof(T);
            T obj = Activator.CreateInstance<T>();
            if (row != null)
            {
                foreach (DataColumn column in row.Table.Columns)
                {
                    PropertyInfo prop = objType.GetProperty(column.ColumnName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
                    object value = row[column.ColumnName];
                    if (value.Equals(DBNull.Value))
                        value = null;

                      prop.SetValue(obj, Convert.ChangeType(value, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType), null);
                   
                }
            }

            return obj;
        }

To convert Generic Collection(GC) to DataTable(DT) you can use bellow code snippet.

Pass the List object in bellow function and it will return DataTable(DT).

        public static DataTable ListToDataTable<T>(List<T> list)
        {
            DataTable dt = new DataTable();

            foreach (PropertyInfo info in typeof(T).GetProperties())
            {
                dt.Columns.Add(new DataColumn(info.Name, Nullable.GetUnderlyingType(info.PropertyType) ?? info.PropertyType));
            }
            foreach (T t in list)
            {
                DataRow row = dt.NewRow();
                foreach (PropertyInfo info in typeof(T).GetProperties())
                {
                    row[info.Name] = info.GetValue(t, null) != null ? info.GetValue(t, null) : DBNull.Value;
                }
                dt.Rows.Add(row);
            }
            return dt;
        }

References:
http://bit.ly/gck7q4
http://bit.ly/ebDP0Q

Posted in .Net, Technical | Leave a Comment »

2010 in review

Posted by Navi's on January 2, 2011

The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here’s a high level summary of its overall blog health:

Healthy blog!

The Blog-Health-o-Meter™ reads Fresher than ever.

Crunchy numbers

Featured image

A Boeing 747-400 passenger jet can hold 416 passengers. This blog was viewed about 1,500 times in 2010. That’s about 4 full 747s.

In 2010, there were 14 new posts, not bad for the first year! There were 23 pictures uploaded, taking up a total of 672kb. That’s about 2 pictures per month.

The busiest day of the year was October 29th with 109 views. The most popular post that day was Great achievment of Bhakti Singhwane.

Where did they come from?

The top referring sites in 2010 were google.co.in, google.com, en.forums.wordpress.com, linkedin.com, and ramanisandeep.wordpress.com.

Some visitors came searching, mostly for modifystyle, bhakti singhwane, update table add column, javascript change class value, and white screen on desktop active desktop recovery.

Attractions in 2010

These are the posts and pages that got the most views in 2010.

1

Great achievment of Bhakti Singhwane October 2010
1 Like on WordPress.com,

2

Modify Style css class value by Javascript March 2010
9 comments

3

How to Add/Update Table Column Description using Query January 2010
1 comment

4

Dropdownlist with checkbox July 2010
1 comment and 1 Like on WordPress.com,

5

Find any text in Sql server Database February 2010
1 comment

Posted in Uncategorized | 1 Comment »

Great achievment of Bhakti Singhwane

Posted by Navi's on October 25, 2010

Bhakti Singhwane

Bhakti Singhwane participated in 10’th All India Dance and Drama Competition, recently organised by Gurgaon-based Nistha Sanskritik Manch (NSM). She participated first time in national level Dance Competition and got the 1’st Prize in solo dance competition and 2nd Prize in group dance. Her age is only 8 years.

She is learning dance under the guidance of Vaishali Patil.

Artistes from across the India (28 states) participated in the meet staged at the spacious and multi-screen amphitheatre of the Rotary (International) Public School (RPS) in Sector 22.

Click here to view Bhakti’s Dance

Read more: देश भर से आए कलाकारों ने बांधा समां
नाटकों ने छुआ मन तो डांस ने झुमाया

Posted in General | Leave a Comment »

Dropdownlist with checkbox

Posted by Navi's on July 15, 2010

Some times we need a DropDownList with checkbox. Either we use some ready made controls like Infragistics WebDropDown or create your own with TextBox, CheckBoxList and AjaxControlToolkit.

So, If we want to create our own DropDownList with checkbox we need first AjaxControlToolkit. You can download it from here.

We will use PopupControlExtender control. So lets start.

First add the one TextBox control and set some properties of its.

<asp:TextBox ID="txtDropDown" runat="server" Text="Select" ReadOnly="true" Style="background: url(DropDownarrow.png) no-repeat right; border: solid 1px #7F9DB9; padding-right: 30px;"></asp:TextBox>

Now Put Panel control with some default settings. Add CheckBoxList control within the Panel and PopupControlExtender control after the panel .

<asp:Panel ID="pnlDDL" runat="server" BackColor="White" Style="border: solid 1px #7F9DB9; overflow: auto; overflow-x: hidden; display: none; height: 250px; width: 250px;">

<asp:CheckBoxList id="chkList" runat="server"/>
</asp:Panel>

<ajaxtoolkit:PopupControlExtender runat="server" ID="popExtDDL" TargetControlID="txtDropDown" PopupControlID="pnlDDL" Position="Bottom" />

That’s it. Now you can Bind the CheckBoxList control with DataSource and it will show you the dropdown with CheckBox.
If you want to add the select all checkbox you can add the checkbox above the CheckBoxList. You can use simple HTML control checkbox control.

<input type="checkbox" id="chkAll" style="margin-left: 3px; display: none; font-size: 8pt" /><span style="font-size: 8pt;">Select All</span>

And use the jQuery for select all. To use jQuery you need to include the jQuery library in your page. You can download it from here.

 $(document).ready(function() {
            $('#chkAll').click(function() {
                $("#<%= chkList.ClientID %> input:checkbox").attr('checked', this.checked);
            });
});

This is the benefit of jQuery.

Now we need to selected items of CheckBoxList. For this we can use LINQ in place of looping.

IEnumerable<int> allChecked = (from item in chkList.Items.Cast<ListItem>()
                               where item.Selected
                               select int.Parse(item.Value));

This will return you the collection of selected items.

References:
http://bit.ly/99luaN

Posted in .Net, Javascript | 1 Comment »

Directly call on IVR

Posted by Navi's on June 23, 2010

Most of the time we call the customer care or other number those uses the IVR i.e. Interactive voice response system.

If we need to call directly on IVR number without waiting we can do this easily using “p” i.e. pause. For example, suppose your Customer care number is

12345678 and you need to go to by press 1 than 2 and than 4.

You can reach directly to 4 using this trick. You just need to to like this

12345678p1p2p4” it will take you to directly on 4.

By pressing * button 3 times in Nokia mobile you can get that “p” i.e. pause. And other mobile you have to hold the * key till you get the “p” on screen.

Posted in General | Tagged: | 2 Comments »

Active Desktop Recovery Error

Posted by Navi's on June 10, 2010

Some time we saw this “Active Desktop Recovery Error” on Desktop. When this error comes our desktop wallpaper has been replaced with this error.

Active desktop recovery error

To Resolve this error we have to change in registry setting.

Go to Run window using Win + R.
Type the command “regedit”
Navigate the Tree
HKEY_CURRENT_USER–>SOFTWARE–>MICROSOFT–>INTERNET EXPLORER–>DESKTOP–>SAFEMODE–>COMPONENTS

In here you can find “DeskHtmlVersion” key just modify its value 0.

Same change in here
HKEY_CURRENT_USER–>SOFTWARE–>MICROSOFT–>INTERNET EXPLORER–>DESKTOP–>Components

In here you can find “DeskHtmlVersion” key just modify its value 0.

After this log-off/restart your computer and log in again you will see your wallpaper.

Share

Posted in Technical | Leave a Comment »

Drag n Drop in asp.net

Posted by Navi's on June 9, 2010

To Implement the drag n drop functionality in Web application we can use different api’s.
But we can achieve this without using any api.

DND requires three basic events i.e. onmousedown, onmousemove and onmouseup.

You can achieve the DND using these three events. So, on onmousedown you can get the dragged control-id and change its x and y position on onmousemove event. and on onmouseup event drop that control.

To find out the drag able control we apply additional class on it and give any name to that class. you can define that class on style-sheet of on page in style like this

.drag{ 
       cursor:default;
       height:50;
       width:50;
       background-color:red; 
 }

Apply this drag class to identify the div using class name.

<div class='drag' id=d1/>

first create the OnDrag function which identify the event and control to be move

var draged = false
var dragElement
var x, y

function OnDrag(event) {
              if (event == null)
                    event = window.event;

 var target = event.target != null ? event.target : event.srcElement;

 if (target.className == "drag") {
		y = event.clientY;
                          x = event.clientX;
}
 
 document.onmousemove = OnMouseMove;

return false;
}

On OnMouseMove Event


function OnMouseMove(event) {
  if (event == null)
                  event = window.event;

if ((event.button == 1 && draged && window.event != null || event.button == 0 && draged) && dragElement.className == "drag") {
                  dragElement.style.left = event.clientX - x - document.body.scrollLeft + 'px';
                  dragElement.style.top = event.clientY - y - document.body.scrollTop + 'px';
                  return false;

}

On OnMouseUp event


 function OnMouseUpEvent() {
draged = false;
}

This is the basics of DND. You can modify as per your requirement.

Posted in .Net | 2 Comments »

Funny statments used in IT :)

Posted by Navi's on May 25, 2010

Some funny statements used during Development and Testing in IT

1) Query Mari (i.e. executed Query)
2) Fat Gaya (i.e. Getting error/exception)
3) Condition me nahi Ghusa (i.e. Condition not satisfied)
4) Application Tapak gayi (i.e. Application Crashed)
5) Naya Build Mara (i.e. New Version Release)
6) Balli laga di (i.e. temporary solution)
7) Utha ke Chipka de (i.e. Copy Paste)

If you found more you can comment it… 🙂

Posted in Funny | 1 Comment »

Get slowest query in SQL server database

Posted by Navi's on May 20, 2010

Using this query we can identify the slowest query which is executing in database.
To execute this you must have a sufficient privileges other wise you will get this error.

The user does not have permission to perform this action.

SELECT TOP 10 SUBSTRING(qtext.TEXT, (qstats.statement_start_offset/2)+1,
((CASE qstats.statement_end_offset
WHEN -1 THEN DATALENGTH(qtext.TEXT)
ELSE qstats.statement_end_offset
END - qstats.statement_start_offset)/2)+1),
qstats.execution_count,
qstats.total_logical_reads, qstats.last_logical_reads,
qstats.total_logical_writes, qstats.last_logical_writes,
qstats.total_worker_time,
qstats.last_worker_time,
qstats.total_elapsed_time/1000000 total_elapsed_time_in_S,
qstats.last_elapsed_time/1000000 last_elapsed_time_in_S,
qstats.last_execution_time,
qplan.query_plan
FROM sys.dm_exec_query_stats qstats
CROSS APPLY sys.dm_exec_sql_text(qstats.sql_handle) qtext
CROSS APPLY sys.dm_exec_query_plan(qstats.plan_handle) qplan
ORDER BY qstats.total_logical_reads DESC -- Order by Logical Reads

You can try this in order by also

ORDER BY qstats.total_logical_writes DESC -- Order by Logical Writes
ORDER BY qstats.total_worker_time DESC -- Order by CPU Time

Posted in SQL Server | Leave a Comment »