Tuesday, February 16, 2010

Detecting if .net framework is installed

Whenever we are to install our application on the client side we have to check if the system is having .net installed or not. One way of doing is to make a setup project in .net and them defining the prerequisites that are required before installing the application. The setup will automatically check the system against all the prerequisites defined and if not installed will prompt the user to install them.

Now in the pop-up window opened select the prerequisite button.

A new pop-up is opened where you will see a list of available prerequisites. Check the desired applications that you need to install before installing your application. Here you can select the .net framework also. Further you will see that there are two option for installing the prerequisites. First one is from the vendor website and the other one is from the the location of your application. Check the second option. The click OK. Now when you will build your setup the .net framework exe will be automatically be created within the bin directory of your setup. Now when you will run the setup on a machine that is not having the .net framework installed it will automatically install it.

Saturday, February 13, 2010

Installing Sql-server 2005 express edition using C#.net

In the previous post i had discussed how to install sql-server 2005 express using command prompt. Today I am going to discuss how to install it using C#.net code. The code for it is as follows:

using System.Diagnostics;

void InstallExpress()
Process p = new Process();
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.FileName = Application.StartupPath.Trim() + @"\SqlServer2005 Express\SQLEXPR.EXE";
            psi.Arguments = "/qn username=\"CustomerUsername\" companyname=\"OurCompany\" addlocal=ALL  disablenetworkprotocols=\"0\" instancename=\"MyInstance\" SECURITYMODE=\"SQL\" SAPWD=\"mypassword\"";

            p.StartInfo = psi;

This is quite simple and easy to implement. Here we have created a process that would run the commands to install the sql-server 2005 express in silent mode.

Thursday, February 11, 2010

Installing Sql-server 2005 express edition using cmd (Silent Mode)

Today I am going to share how to install sql-server 2005 express edition using cmd (command prompt) which is also known as silent mode or non-interactive mode. Also refer to my post regarding performing silent install of sql-server 2005 using C#.net. This method of installation is very helpful if one is bundling the sql-server 2005 express edition with another product which is going to use it. The command prompt parameters are as follows:
start /wait C:\SQLSERVER2005\SQLEXPR32.EXE /qb username="CustomerUsername" companyname="OurCompany" addlocal=ALL  disablenetworkprotocols="0" instancename="MyInstance" SECURITYMODE="SQL" SAPWD="MyPassword"

This would successfully install the sql-server 2005 express edition to the system. Now to login into the sql-server use the following command in cmd:

sqlcmd -S PC100\MyInstance -U sa -P MyPassword

After successful login we would require to attach a database. To attach a database use following command:

( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\MyDB_Data.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\MyDB_log.ldf' )

This would successfully attach the database. Now you are ready to use the database.

Monday, February 8, 2010

Copying records from one table to another

I'll use the SELECT statement in conjunction with the INSERT statement to make this as easy as possible. Normally, I would code an INSERT statement something like this (using the pubs database):
INSERT authors (au_id, au_lname, au_fname, contract)
VALUES ('123-45-6789', 'Gates', 'Bill', 1)
This will insert one row into the authors table. I could write a program to loop through a set of records and insert them one at a time into another table. SQL Server is designed for set processing. It is optimized to handle groups or sets of records. I can actually replace the VALUES clause with a SELECT statement that will return a set of records. Suppose I have a table called INDIA_AUTHORS and we want to populate it with the ID and names of the authors from California. The statement would look something like this:
INSERT india_authors (au_id, au_lname, au_fname)
SELECT au_id, au_lname, au_fname
FROM authors
WHERE State = 'UP'
This will take the 15 records with State='UP' and load them into the table INDIA_AUTHORS. I can use any type of SELECT statement here. It just has to return a record set that matches the columns in the INSERT statement. The number of columns and their data types must match (or be implicitly convertible). I can also execute a stored procedure that returns a record set using the EXEC command in place of the SELECT statement.

Friday, February 5, 2010

Compression in IIS

 A great feature that IIS provides is of compression that helps in improvement of website performance. Few points regarding IIS compression are below:
  • Http compression can make a big difference to performance if bandwidth (size) is the issue, especially if you are talking to non-local clients - and is worth including in most web applications
  • if your pages are slow because of how the processing at the server works, it won't make any difference at all... it only improves the server -> client measure
  • it requires a client (browser) that accepts compression (although this is negotiated in the http headers, so it should "fail safe" for old clients)
  • but you need to watch out; if you still support IE 5?6?, there are a number of major bugs here (especially with ajax etc) - test on the clients you expect to see
  • use Fiddler to check that it is working (as a developer, Fiddler should be one of your closest friends...)
For compression in IIS 7 refer to this article.
To activate HTTP compression in IIS 6:
  1. Launch the IIS Management MMC snap-in (shortcut inetmgr).
  2. Locate the 'Web Sites' node in the left hand side tree pane.
  3. Right click on 'Web Sites' then select 'Properties'.
  4. Click on the Services tab.
  5. Choose the HTTP compression type from the HTTP compression panel.
  6. Click OK.

For more details on compression in IIS 6 refer MSDN
In IIS 6, setting compression this way (using IIS's own compression mechanism) is all or nothing for all your sites. Check link to the TechNet article on how to use adsutil to gain more fine grained control over this.

Wednesday, February 3, 2010

New Features in .net 4.0

After searching a lot i have come forward with a compiled list of main features that are in .net 4.0. Though this list is not exhaustive. Further I have given links that would elaborate the topic more. For more complete official features see this whitepaper from Microsoft detailing many of the new features in ASP.NET 4.0.

There's a couple of videos on Mircosoft Channel 9:

The list is as follows:.
o   Type Equivalence (noPIA)

Ø  Languages
o   C#
§  dynamic keyword
§  Named / optional arguments
§  Co/contra-variance support in delegates and interfaces
o   VB.NET
§  Auto Properties
§  Lambdas with no return value
§  Multi-line lambdas
§  Collection Initializers
§  Automatic Line Continuations
o   F#
§  IronRuby (out of band release)

o   Reactive Extensions (IObservable)
o   Location / GPS APIs
o   Large Numbers (BigInteger, Complex Numbers)
o   Tuples / SortedSet
o   ObservableCollection moved to System.dll
o   Lots of random, helpful, API changes:
§  Enum.HasFlag
§  Enum.TryParse
§  Stream.CopyTo(Stream)
§  Guid.TryParse
§  IEnumerable File.EnumerateFiles()
§  IEnumerable File.ReadLines()
§  String.Join(IEnumerable)
§  String.Concat(IEnumerable)

o   Extensible Output Caching (OutputCacheProvider)
o   SEO improvements (access to page metadata)
§  Areas (Admin areas)
§  Validation (annotations; support for jquery)
§  Type templates
o   ASP.NET WebForms

Ø  WPF (also)
o   Windows 7 Multitouch
o   Windows 7 Shell integration (Taskbar windows, taskbar progress)
o   Cached Compositions
o   Pixel Shader 3
o   DLR databinding support
o   New XAML/BAML parser
o   Visual State Manager (from Silverlight)

o   Multitouch + gestures
o   Printing support
o   CoreCLR / CLR compatability (single compilation)
o   Webcam / Microphone Support
o   Mousewheel support
o   Official Google Chrome support
o   200% faster (supposedly)
o   H.264
o   Video streaming support
o   Out-of-browser applications
§  Host HTML
§  Toast (bubble) notifications
§  Window chrome customisations
o   Trusted out-of-browser applications
§  User folder read-write access (my documents, etc)
§  COM automation
§  Privilage elevation dialog

o   Completely Rewritten
o   Persistance Ignorance / POCO Support
§  Comparison or virtual members
o   Model-first / Database Generation Support
o   T4 Code Generation
o   Lazy Loading
o   "Client" entities that track their own changes
o   Code-only developer support (no edmx xml)

o   Completely rewritten
o   XAML (codeless) design
o   Limited BC with WF3

o   Static Code Analysis (class coupling, etc)
o   Task debugging support (task stack visualisation)
o   Add Reference dialog defaults to Project; .NET tab is asynchronous
o   Code navigation (CTRL+COMMA to find resource by name)
o   Editor written in WPF / MEF
o   No more "team" editions. Only Professional, Premium and Ultimate
o   "Data Dude": redistributable command line for comparing and updating databases (Premium/Ultimate)
o   Test features: ability to record video + steps of bugs for reproduction (Premium/Ultimate)

Further features module wise (not exhaustive) is as follows:

 Web Forms
Ø  Developers can manage control IDs that affect rendered client ID
Ø  Remove ID bloat, and 'mangling'
o   Ideally remove the need to use CSS adapters
o   Defer to CSS styles and bypass existing style properties
§  non-inline style attributes
o   Support non-table-based HTML rendering
Ø  URL-routing for web forms
o   Friendly url handling for web forms
o   configuration model for url routing
Ø  View state
o   Disable on the page, enable on specific controls - they will provide granular control of viewstate - today it is backwards
o   Disable on control, enable on child controls
o   GridView/ListView work better without viewstate
Ø  ASP.NET dynamic-data

Ø  Continue ASP.NET Ajax innovation : RIA
Ø  Appeal to JavaScript Developers
Ø  Provide support for the page developer
Ø  jQuery including Intellisense
Ø  Templates and data binding
o   Client side handling, REST or Web Services
o   Covers page developer and component developer scenarios
Ø  DOM manipulation, selectors ...
Ø  Ajax higher-level components
o   Ajax Control Toolkit is a part of the strategy - they will make the toolkit part of the overall ASP.NET package
o   New controls
Ø  Centralized script libraries and break-up for performance

Ø  Appeal to those wanting separation of concerns, TDD, full control
Ø  Ruby on Rails, Django, PHP
Ø  Building on from ASP.NET MVC 1.0
Ø  ASP.NET MVC (Model View Controller)
Ø  Asynchronous controllers
Ø  Sub-controllers & Views
Ø  Declarative controls

Ø  Address customer pain points
Ø  Improve scale and performance
Ø  Cache extensibility and performance:
o   Enable caching like Velocity

Tuesday, February 2, 2010

Differences in Sql Server 2005 and Sql Server 2008

Here I have sorted out a list of features that are new to MS SQL Server 2008 and enhances the productivity and output of both the database and the users using them. The list is not exhaustive but covers most of the key features. The list is as follows:

·         Transparent Data Encryption. The ability to encrypt an entire database.
·         Backup Encryption. Executed at backup time to prevent tampering.
·         External Key Management. Storing Keys separate from the data.
·         Auditing. Monitoring of data access.
·         Data Compression. Fact Table size reduction and improved performance.
·         Resource Governor. Restrict users or groups from consuming high levels or resources.
·         Hot Plug CPU. Add CPUs on the fly.
·         Performance Studio. Collection of performance monitoring tools.
·         Installation improvements. Disk images and service pack uninstall options.
·         Dynamic Development. New ADO and Visual Studio options as well as Dot Net 3.
·         Entity Data Services. Line Of Business (LOB) framework and Entity Query Language (eSQL)
·         LINQ. Development query language for access multiple types of data such as SQL and XML.
·         Data Synchronizing. Development of frequently disconnected applications.
·         Large UDT. No size restriction on UDT.
·         Dates and Times. New data types: Date, Time, Date Time Offset.
·         File Stream. New data type VarBinary(Max) FileStream for managing binary data.
·         Table Value Parameters. The ability to pass an entire table to a stored procedure.
·         Spatial Data. Data type for storing Latitude, Longitude, and GPS entries.
·         Full Text Search. Native Indexes, thesaurus as metadata, and backup ability.
·         SQL Server Integration Service. Improved multiprocessor support and faster lookups.
·         MERGE. TSQL command combining Insert, Update, and Delete.
·         SQL Server Analysis Server. Stack improvements, faster block computations.
·         SQL Server Reporting Server. Improved memory management and better rendering.
·         Microsoft Office 2007. Use OFFICE as an SSRS template. SSRS to WORD.
·         SQL 200 Support Ends. Mainstream Support for SQL 2000 is coming to an end.

Good intro article part 1, part 2, part 3. As for compelling reasons, that depends on what you are using SQL server for. Do you need hierarchical data types? Do you currently store files in the database and want to switch over to SQL Server's new filestream feature? Could you use more disk space by turning on data compressionAnd let's not forget the ability to MERGE data. 

But be aware that a lot of the really killer features are only in Enterprise Edition. . See microsoft.com/sqlserver/2008/en/us/…

Data compression and backup compression are among two of my top favorites - they give you free performance improvements right off the bat. Data compression lessens the amount of I/O you have to do, so a lot of queries speed up 20-40%. CPU use goes up, but in today's multi-core environments, we often have more CPU power but not more IO. Anyway, those are only in Enterprise.
If you're only going to use Standard Edition, then most of the improvements require changes to your application code and T-SQL code, so it's not quite as easy of a sell.
In Sql server 2005, there is no option to compress backup files, but in sql server 2008, there you find it. Storing backup file takes 5 minutes without compression in sqlserver 2005, but it takes only 3 minutes in Sql server 2008 for storing backup files with compression.

Change Tracking. This was the obvious feature that all were anticipating. It would make the life of the developer a lot easier as he can track the changes. Allows you to get info on what changes happened to which rows since a specific version.

Change Data Capture. Allows all changes to be captured and queried. (Enterprise)

SQL 2008 also allows you to disable lock escalation on specific tables. I have found this very useful on small frequently updated tables where locks can escalate causing concurrency issues. In SQL 2005, even with the ROWLOCK hint on delete statements locks can be escalated which can lead to deadlocks. 


Related Posts with Thumbnails