Thursday, December 26, 2013

Use of @(at the rate) in file path


  • In a string literal Prefixed with @ symbol the escape sequence appear as a normal character without being treated them differently.
  • For eg. @"C:\A\B\C" is same as "C:\\A\\B\\C" ,but first one looks a lot nicer.

Tuesday, December 24, 2013

Text to Speech in C#

First Add Reference:-System.Speech

NameSpace required:-using System.Speech.Synthesis

Code:-


Text Spammer in C#

Class and method used to implement Text Spammer:-

SendKeys Class:-Provides methods for sending keystrokes to an application.

Send Method:-Sends keystrokes to the active application.

Design Part:-






Code Behind Part:-




















Output:-





Note:-Below link is used to find code for keys to pass as an argument in the send method of sendkeys class.

http://msdn.microsoft.com/en-us/library/k3w7761b%28v=vs.71%29.aspx



Friday, December 20, 2013

Identity Vs Uniqueidentifier primary key


  • The reason why people suggest you avoid the unique identifier data type is complicated.  You need to understand how things work "behind the scenes".
  • First, let's investigate what happens with an integer key set to Identity(1,1).  Primary keys are implemented through indexes.  SQL Server stores index data on the hard drive.  All data is stored in 8 kilobyte pages (including indexes).
  • Now, an integer takes 4 bytes, so you can store roughly 2,000 values in an index page.  Data in an index is sorted, which is why index searches are so much faster.  Finally, consider what happens when you add a new value.  Since this is an identity column, the new value is guaranteed to be larger than any existing piece of data, so it will be added to the end of the list.  If the last data page is NOT full, SQL Server simply writes the data to the end of the last index page.  If the page happens to be full (which will only occur once every 2000 inserts), then a new page is allocated and the new value is written to the first spot if the newly allocated data page.
  • Now let's think about the uniqueidentifier primary key.  A uniqueidentifier requires 16 bytes per value, so the most you can fit in an 8K data page is 500 values.  This means your index will be 4 times larger simply because of the data type.  This also means that joins and searches will be slightly slower too.  It takes more time to compare a 16 byte value than it does to compare a 4 byte value.
  • More importantly, think about the data stored in the index. If you use NewId() to create your unique identifer, you can run in to some serious performance problems. Remember earlier I said that the data in an index is sorted.  This also holds true for unique identifiers.  NewId() will return a unique number which is likely to fall somewhere in the middle of your existing numbers. So.... when you insert a row, SQL needs to determine which data page to store the new value, then, if the data page is full, it must split the page in to 2 pages.  1/2 the data from the existing page is copied to the new page (leaving each page 1/2 full), and then the new value is inserted.  Even if the page isn't full, most of the time, the data in the page will need to be rearranged to accommodate the new piece of data (some of the rows will need to be pushed down so that the new value can be inserted in to the correct spot).
  • This problem occurs if you use the NewId() function for your unique identifier.  If you use the NewSequentialId() function, there is less of a problem because you are guaranteed to get a GUID that is greater than your existing values.  Your new value will be inserted at the end, and you won't have page splits to worry about.  You still have a 16 byte value to compare with other 16 byte values (instead of 4 byte integers), so your joins and filters will be slightly slower than if you had used integer keys.  
  • It's important to put this in to perspective.  If you have a table with 10's of millions of rows, with inserts, updates, and deletes occurring 100's or 1000's of times per second, then you really need to worry about this stuff.  With smaller tables that have less usage, it really doesn't matter because you will not notice the performance issues that this can cause.

Use of Rowguid in Sql Server

Rowguid:-

  • To ensure global uniqueness for the purposes of replicating the table using merge replication.
  • Row Guid is designed for make a row id unique  across, tables ,databases, or even databases  over network computers. 
  • Although the IDENTITY property automates row numbering within one table, separate tables, each with its own identifier column, can generate the same values. This is because the IDENTITY property is guaranteed to be unique only for the table on which it is used. If an application must generate an identifier column that is unique across the database, or every database on every networked computer in the world, use the uniqueidentifier data type and the NEWID (Transact-SQL) or NEWSEQUENTIALID() function. The Database Engine does not automatically generate values for the column. To insert a globally unique value, create a DEFAULT definition on the column that uses the NEWID() or NEWSEQUENTIALID() function to generate a globally unique value.

How to Create rowguid column??



Thursday, October 31, 2013

Microsoft SQL Server 2008, Implementation and Maintenance

MCSA : SQL Server 2008 70-432 TSQL Exam Paper with Solution

You work as a database administrator at ABC.com. ABC.com is planning to migrate a SQL Server 2000 application to SQL Server 2008 R2.After the migration, you want to keep an eye on the performance of the SQL Server 2008 R2 instance.   You then configure a SQL server-side trace that captures the Deprecation Announcement and Deprecation Final Support event classes.
Which two of the following best describes these two event classes respectively? (Choose two.)

A. The Deprecation Final Support event class reveals that a feature will be removed in the next important
release of SQL Server.
B. The Deprecation Announcement event class reveals that a feature will be removed in the next important
release of SQL Server.
C. The Deprecation Announcement event class reveals that a feature will be removed in an upcoming edition
of SQL Server.
D. The Deprecation Final Support event class reveals that a feature will be removed in an upcoming edition of SQL Server.

Correct Answer: AC

You work as a database administrator at ABC.com. ABC.com makes use of a SQL Server 2008 R2 instance that includes an On-Line Analytical Processing (OLAP) database.
The OLAP database hosts a dimension table, named ABCClients, which has hourly information updates configured. As a result, ABCClients has a large quantity of information that is no longer used. You have been instructed to make sure that the amount of space used by the ABCClients table is reduced with as little administrative effort as possible.
Which of the following actions should you take?
A. You should consider manually deleting the information that is no longer used.
B. You should consider making use of page compression.
C. You should consider making use of the Disk Cleanup Wizard.
D. You should consider making use of folder compression.


Correct Answer: B




Tuesday, October 22, 2013

How to move Application to Cloud

Move Application to Cloud


Application belongs to Adatum to keep a track, Submit and also the business process expenses. A datum’s policy is to submit their monthly Expenses to the Company for Reimbursement.
                                                             
Install the setup, open DependencyChecker.exe


When DependencyChecker.exe is clicked, it displays the list of pre requisites to be installed. Install all the Prerequisites




Now open the desired project
File -> Open -> Project/solution -> aExpense.sln



Now debug the project




After the Debug is started the output is then ready to appear in a browser


It now shows the site’s security certificate is not trusted!
Click Proceed anyway





Click on ADATUM\johndoe(Group: ‘Employee’)
Continue with login should be clicked



Enter DATE: TITLE:
Description,
 Amount,
In drop down select REIMB.METHOD as Cash and APPROVER ADATUM\mary
Add receipt by clicking browse



Adding Lunch and Dinner

 




OUTPUT:


Logging into manager’s role:
Manager can now login and review the reimbursements


He now has the authority to approve it


 
Worker can cross check it by logging into his account again

Saturday, August 10, 2013

Use of Sub Query in Asp.Net

Sub Query

1)StateMaster Table

Column Name:-Id,State

2)CityMaster Table

Column Name:- Id,StateId,City

Question:- How to retrieve Column City,State from Table CityMaster,StateMaster respectively?

Answer:- select *,(select [State] from StateMaster where StateMaster.Id=StateId) as [State] from CityMaster 




Tuesday, May 28, 2013

Required Field Validation for Ajax Combobox

Required field validation not working with Ajax combobox

Reason:-

Combobox doesn't rendered as a dropdownlist. Infact,it is interpreted as a textbox.So,required field validation with initial value attritube="(selected value)" will not work.It required to set initial 
value = "--Select--"  in order for combobox satisfied your required field validation.

<asp:ComboBox ID="ComboEMINo" runat="server"  AutoPostBack="true" >
</asp:ComboBox>
 <asp:RequiredFieldValidator ID="rfvEMINo" ControlToValidate="ComboEMINo" runat="server"
 ErrorMessage="Select EMINo." ForeColor="Red" InitialValue="--Select--">*</asp:RequiredFieldValidator>


Thursday, February 28, 2013

How to put Asp.net site under maintainence

Placed Live Asp.net site under maintainence or monitering
Firstly create App_Offline.htm file in the root of your asp.net website.Define your markup for the end user to display in this file when your live website is under maintainence or monitering session.Now,whenever you view any of your website page it will show code on your App_Offline.htm file.

After ajaxify the pages gridview rowcommand event not firing on page refresh

Problem:
I have an .aspx where i am loading gridview data for the first time using (!ispostback).On the same page i have a linkbutton which fires a Modelpopup extender which has a target id of panel which includes two textbox,one file upload and two button controls.In the gridview i have two button column for edit and delete.But when i load the page for the first time,gridview rowcommand is not firing.
1)So,how should i wrap the code in order to fire the gridview rowcommand events.
2)In the panel i have two button controls and none of there click is binding to the code behind.so how to fire these two controls events.
Please mention your valuable comments and help me out.

Wednesday, January 16, 2013

Mystery behind app_offline.htm file is solved!!!


What is app_offline.htm file?
Asp.net framework avail offline mode of web application to perform some update and data transfer operation on production server.In offline mode application does not respond to request made for dynamic web page.So,when a request for web page is made from an application in offline mode,it return error message to the user which states:

"This application is currently offline.To enable the application, remove the app_offline.htm file from the application root directory."

Above error message is returned to user using app_offline.htm file.Therefore,app_offline.htm file is used to send customized error message to all user who request dynamic pages from application in offline mode.

How app_offline.htm file is created?
SQL Server 2005 express edition and its superceded editions does not support multiple processes.Only single process can access database at a one time.So,when database is accessed through visual studio, visual studio's integrated web server,also known as cassini cannot access database.This will result to internal server error.To prevent these,visual studio places app_offline.htm file under the root of your web application,which put your application in offline mode.










Tuesday, January 15, 2013

What is DataDirectory in Asp.net?

In Asp.net, DataDirectory (which is enclosed in a pipe symbol in a connection string) is a replacement string which indicate path to your database file and also eliminate the need to hard-code the full path to your database file as .

By default DataDirectory refers to  App_Data folder under the root of your web application.For Desktop application, DataDirectory points to bin directory.So,now the question is what is we wanted DataDirectory to point to a different location(other than App_Code folder)?

The issue can be resolved using AppDomain.And the following line will set DataDirectory path before using it in connection string.

AppDomain.CurrentDomain.setData("DataDirectory",@"c:\Data\");

That would make your DataDirectory to point to "c:\Data\database.mdf path.