Pages

Sunday, May 5, 2013

Gridview Custom Paging and Sorting in Asp.net

Introduction
Today we are working with GridView custom sorting and paging without using any datasource control in Asp.net. Gridview is flexible enough to perform these tasks without the use of any datasource control and only a few lines of code. For paging a Gridview manually we have to handle the Gridview’s PageIndexChanged Event. In the event we need to change the PageIndex of Gridview to the page that user has clicked and again bind the Gridview.
Gridview Paging.
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
      GridView1.PageIndex = e.NewPageIndex;
      GridView1.AllowPaging = true;
      GridView1.PageSize = 3;    
      GridView1.DataBind();
 }
This is all you need to do to make manual paging in the Gridview.
Gridview Sorting
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
 {
      DataTable _dataTable = GridView1.DataSource as DataTable;
      if (_dataTable != null)
       {
          DataView _dataView = new DataView(_dataTable);
          _dataView.Sort=e.SortExpression + "" + getDirection(e.SortDirection);
          GridView1.DataSource=_dataView;
          GridView1.DataBind();
       }
 }
   
private string getDirection(SortDirection _sortDirection)
 {
      string _newDirection = string.Empty;
      if (_sortDirection == SortDirection.Ascending)
      {
          _newDirection = "ASC";
      }
      else
      {
          _newDirection = "DESC";
      }
      return _newDirection;
 }
And we have the manual sorting for the Gridview. 

Thursday, May 2, 2013

Advantage of Sql Server 2008 over Sql Server 2005

 Introduction
This article is explaining advantage of Microsoft Sql Server 2008 over Sql Server 2005.

Sr No
SQL Server 2005
SQL Server 2008
1
XML datatype is introduced.
XML datatype is used.
2
Can not encrypt the entire database.
Can encrypt the entire database introduced in 2008.
3
Datetime is used for both date and time.
Date and time are seperately used for date and time
4
No table datatype is included.
Table datatype introduced.
5
SSIS is started using.
SSIS avails in this version.
6
CMS is not available.
Central Management Server(CMS) is Introduced.
7
PBM is not available
Policy based management(PBM) server is Introduced.

There are following new feature of Microsoft Sql server 2008 over Sql Server 2005.
  1.  SQL server 2008 has the ability to encrypt the entire database by using (TDE)).I.e  transparent data encryption. Where as in sql server 2005 we have cell-level encryption.
  2. SQLserver 2008 provides Backup encryption and that will executed at backup time to prevent tampering.
  3. External Key Management. Storing Keys separate from the data.
  4. With SQL Server Audit, SQL Server 2008 introduces an important new feature that provides a true auditing solution for enterprise customers. While SQL Trace can be used to satisfy many auditing needs, SQL Server Audit offers a number of attractive advantages that may help DBAs more easily achieve their goals such as meeting regulatory compliance requirements. These include the ability to provide centralized storage of audit logs and integration with System Center, as well as noticeably better performance.
  5. Data Compression. Fact Table size reduction and improved performance.
  6. Collection of performance monitoring tools.With Performance Data Collector in SQL Server 2008, you can now store performance data from a number of SQL Servers in one central location. This data is collected by a collection set on each server and stored in a shareable management data warehouse (MDW). Reports can be generated from this data using the built-in reports or generating your own with reporting Services. Brad McGehee explains more.
  7. installation improvements. Disk images and service pack uninstall options.
  8. Dynamic Development. New ADO and Visual Studio options as well as Dot Net 3.
  9. Entity Data Services. Line Of Business (LOB) framework and Entity Query Language (eSQL)
  10. LINQ. Development query language for access multiple types of data such as SQL and XML.
  11. Data Synchronizing. Development of frequently disconnected applications.
  12. Large UDT(User-defined types). No size restriction on UDT(User-defined types).UDTs were restricted to a maximum size of 8 kilobytes. In SQL Server 2008, this restriction has been removed for UDTs that have a format of UserDefined.
  13. The DATETIME function’s major change in SQL Server 2008 is the four DATETIME data types introduced. They are DATE, TIME, DATETIMEOFFSET and DATETIME2. IN addition to these newly introduced data types, there are new DATETIME functions all well.
  14. FILESTREAM was introduced in SQL Server 2008 for the storage and management of unstructured data. The FILESTREAM feature allows storing BLOB data (example: word documents, image files, music and videos etc) in the NT file system and ensures transactional consistency between the unstructured data stored in the NT file system and the structured data stored in the table. 
  15. Table-Valued Parameters is a new feature introduced in SQL SERVER 2008. In earlier versions of SQL SERVER it is not possible to pass a table variable in stored procedure as a parameter, but now in SQL SERVER 2008 we can use Table-Valued Parameter to send multiple rows of data to a stored procedure or a function without creating a temporary table or passing so many parameters.
  16. sql server 2008 provides Full Text Search. Native Indexes, thesaurus as metadata, and backup ability.
  17. SQL Server Integration Service(SSIS). Improved multiprocessor support and faster lookups.
  18. SQL Server Reporting Server(SSRS). Improved memory management and better rendering.
  19. SQL Server Analysis Services.(SSAS) Stack improvements, faster block com***tions.
  20. One of the fantastic new features of SQL Server 2008 is Merge Statement. Using a single statement, we can Add/Update records in our database table, without explicitly checking for the existence of records to perform operations like Insert or Update.

Tuesday, April 30, 2013

What is Differences between Stored Procedures and Functions

Introduction
This article will be explain what Differences between Stored Procedures and Functions. There are following Differences between Stored Procedures and Functions.
  1. Procedure can return zero or n values whereas function can return one value which is mandatory.
  2. Procedures can have input/output parameters for it whereas functions can have only input parameters.
  3. Procedure allows select as well as DML statement in it whereas function allows only select statement in it.
  4. Functions can be called from procedure whereas procedures cannot be called from function.
  5. Exception can be handled by try-catch block in a procedure whereas try-catch block cannot be used in a function.
  6. We can go for transaction management in procedure whereas we can't go in function.
  7. Procedures can not be utilized in a select statement whereas function can be embedded in a select statement.
  8. UDF can be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section where as Stored procedures cannot be.
  9. UDFs that return tables can be treated as another rowset. This can be used in JOINs with other tables.
  10. Inline UDF's can be though of as views that take parameters and can be used in JOINs and other Rowset operations.
Stored Procedure
A Stored Procedure is a program (or procedure) which is physically stored within a database. They are usually written in a proprietary database language like PL/SQL for Oracle database or PL/PgSQL for PostgreSQL. The advantage of a stored procedure is that when it is run, in response to a user request, it is run directly by the database engine, which usually runs on a separate database server. As such, it has direct access to the data it needs to manipulate and only needs to send its results back to the user, doing away with the overhead of communicating large amounts of data back and forth.
create proc myProc(@a int , @b int)
as
declare @s int
set @s=@a + @b
return @s
to execute procedure
declare @m int
exec @m= myProc 10,20
print @m
User Defined Function
A user-defined function is a routine that encapsulates useful logic for use in other queries. While views are limited to a single SELECT statement, user-defined functions can have multiple SELECT statements and provide more powerful logic than is possible with views.
create function myFunction(@a int, @b int)
return int
as
begin
declare @s int
set @s=@a + @b
return @s
end
To execute function
select dbo.myFunction(10,20)
User defined functions have three main categories:
1. Scalar-valued function - returns a scalar value such as an integer or a timestamp. Can be used as column name in queries.
2. Inline function - can contain a single SELECT statement.
3. Table-valued function - can contain any number of statements that populate the table variable to be returned. They become handy when you need to return a set of rows, but you can't enclose the logic for getting this rowset in a single SELECT statement.

select distinct * into temptable from emp1
delete from emp1

insert into emp1  select * from temptable

Monday, April 22, 2013

Enable USB Port in Windows 8

Introduction
In my previous article we discused how to disable a USB port in Windows 8. This article explains how to enable a USB port in Windows 8. We need to block a USB port when we want to protect our computer from viruses and other vulnerabilites from USB ports. To disable the USB port in the previous article we used a Registry Editor setting so to enable a USB port we can also use the Registry Editor setting. And this example only works for when the USB is blocked by a Registry Editor setting.
How to enable a USB port in Windows 8.
Step 1
Go in the search box and type "Run" and click on the application that is shown or press "Win + R".
Search-In-Windows8.jpg
Step 2
In the run window type "regedit" and click on "OK".
Run-In-Windows8.jpg
Step 3
"Registry Editor" window will be opened.
Registry-Editor-Windows8.jpg
Step 4
In the Registry Editor go to "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR".
USBTOR-Windows8.jpg
Step 5
In the right panel double-click on "Start" and a new window will be opened.
Start-Option-Windows8.jpg
Step 6
In this window type "3" in the value's data and click on "Hexadecimal", click on "OK".
Enable-USB-Setting-Windows8.jpg
Step 7
Restart your computer to apply this setting.
To Disable a USB port visit this link:

Fix Windows Store Apps Error: This App Wasn't Installed

Introduction
The Windows 8 Store is a new feature in Windows 8 by which you can download and install applications and games. Sometimes however when you try to install an application from the Windows 8 Store the installation fails and you get the error message "this app wasn't installed-view details". In some cases it installs about 50% and then just gets stuck there, or you might get some error code or it may just say that it is unable to install it.
In this article we explain how to fix the Windows 8 Store download problem. This type of problem occurs because your Windows firewall may be disabled or a proxy is not set properly.
Error-In-Windows8.jpg
How to fix the Windows 8 Store download problem
Step 1
Open Internet Explorer and click on setting and select "Internet options".
Internet-Explorer-Windows8.jpg
Step 2
A new window will be opened. In this window go to the "Connection" tab and click on "LAN Settings".
Internet-Option-Windows8.jpg
Step 3
In this step click on "Advanced".
Lansetting-Windows8.jpg
Step 4
In this step delete the proxy address and click on "OK" and exit from Internet Explorer.
Proxy-Setting-Windows8.jpg
Step 5
Go to the search box and type "Cmd" and open a command prompt as administrator.
Step 6
In the command prompt enter the command "netsh winhttp set proxy :port". For example: "netsh winhttp set proxy 192.168.1.1:8888" then Enter.
Command-Prompt-Windows8.jpg
Step 7
After setting the proxy you will see your current proxy. Exit from the command prompt.
Set-Proxy-Windows8.jpg
Step 8
Now go to the Windows Store and try to install applications.

Saturday, April 20, 2013

Play MKV Video in Windows 8 Media Player

Introduction
In this article we are going to explain how to play a Windows Media Player (.mkv or .avi extension or H264) file in Windows 8. You perhaps know that the built-in Windows Media Player is not able to open or play the latest video format like .mkv, .avi, flv etc. in each version of Windows. When you try to play this type of file then it shows an error "Windows Media Player can't play this file". This problem also exists with Windows 8.
To solve this problem you have to add an external codecs pack to the Windows Media Player. Because Microsoft provides limited codecs packs with Windows Media Player. After adding a codecs pack you can easily play a .mkv file with Windows Media Player and you can also play .avi, .flv, .ogv, .xvid etc. format files with Windows Media Player.
You can download Windows 8 codecs packs from this link:
How to add external codecs packs to Windows 8 Media Player.
Step 1
First try to play a ".mkv" file with the Windows Media Player. It will show an error.
Not-Suported-Media-Windows8.jpg
Step 2
Download a codecs pack and right-click and select "Run as administrator".
Run-As-Admin-Windows8.jpg
Step 3
Follow the installation steps and finish the installation.
Codec-Windows8.jpg
Step 4
After installing a codecs pack, restart the computer and try to open a .mkv file with Windows Media Player.
Play-Mkv-File-Windows8.jpg

How to Activate Windows 8


Introduction
In this article we are going to explain how to activate Windows 8. To activate Windows 8 you must have a valid product key and network connection.
There are several ways to activate Windows 8 but in this article we are using a command prompt to activate Windows 8 and you can also use this article to change the Windows 8 product key.
How to activate Windows 8
Step 1
Go to the search box and type "Cmd" and right-click on the command prompt icon and select "Run as Administrator".
Run-As-Admin-Windows8.jpg
Step 2
In the command prompt type "slmgr.vbs -ipk <insert your product key here>" and press the "Enter" button. A message will be displayed with the product key in it. In this example we are using the product key for example. You can use another product key for activation.
slmgr.vbs -ipk {insert your product key here}
Insert-Product-Key-Windows8.jpg
Step 3
After inserting the product key type "slmgr.vbs -ato" and press Enter. A message will be displayed informing you that the product was activated successfully.
slmgr.vbs -ato
Insert-Command-Windows8.jpg
Step 4
Now go to the Desktop screen and right-click on the "My Computer" icon and select "Properties". Now you will see "Windows is Activated".
 Windows-Activated-Windows8.jpg