Sunday, June 18, 2006
Tracking file download
private void DownloadFile(string strfile)
{
System.IO.Stream iStream = null;
byte[] buffer = new Byte[1000];
int length;
long dataToRead=-1;
bool startstatus=false;
string filepath = strfile;
string filename = System.IO.Path.GetFileName(filepath);
try
{
iStream = new System.IO.FileStream(filepath, System.IO.FileMode.Open,System.IO.FileAccess.Read, System.IO.FileShare.Read);
dataToRead = iStream.Length;
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
while (dataToRead > 0)
{
// Verify that the client is connected.
if (Response.IsClientConnected)
{
// Read the data in buffer.
length = iStream.Read(buffer, 0, 1000);
// Write the data to the current output
Response.OutputStream.Write(buffer, 0, length);
// Flush the data to the HTML output.
Response.Flush();
buffer= new Byte[1000];
dataToRead = dataToRead - length;
if(startstatus == false)
{
// Started downloading
startstatus=true;
}
}
else
{
//prevent infinite loop if user disconnects
dataToRead = -1;
// disconnected or unable to download
}
}
}
catch (Exception ex)
{
dataToRead = -1;
}
finally
{
try
{
if(dataToRead == -1)
{
// disconnected or unable to download
}
else
{
// file successfully downloaded
}
if (iStream != null)
{
//Close the file.
iStream.Close();
}
}
catch(Exception ex)
{
}
}
}
Tuesday, June 06, 2006
Enterprise Library - June 2005
Caching ApplicationBlock
Configuration Application Block
Data Access Application Block
Cryptography Application Block
Exception Handling Application Block
Logging and Instrumentation Application Block
Security Application Block
The following are the links for learning Enterprise library.
Download Enterprise library
Learning materials
Thursday, May 11, 2006
Windows Sharepoint Service - 3
Create a new IIS Web Site
a. Open IIS Manager
b. Right-Click on Webs Sites, New -> Web Site to open the Web Site Wizard
c. Enter a description of WSS and click Next
d. Leave IP Address and Port unchanged, but enter WSS in the Host Headers field and click Next
** This assumes you have a DNS record for WSS and the server IP
e. Click Browse then create a new folder under c:\inetpub called WSS and select it, then click Next
f. On the screen title Web Site Access Permissions click Next
g. Click Finish to complete the Web Site creation
Extend the new IIS Web Site
By extending a virtual server we are effectively installing WSS onto the Web Site.
a. Open SharePoint Central Administration - Start -> Administrative Tools -> SharePoint Central Administration
b. Ensure Windows SharePoint Services administration is displayed, link in left column
c. Click on Configure Virtual Server Settings
d. Click on the WSS link
e. On the Extend Virtual Server page, click on Extend and create a content database
f. On the Extend and create content database page, select Use an existing application pool, and choose MSSharePointAppPool from the dropdown.
** Additional Application Pools can be configured to separate instances of WSS running on a single server and thereby ensuring a fault in one application does not affect another.
g. Enter and email address, for example administrator@localhost and click OK
** Extending the virtual server may take some time
h. When completed click on http://wss/
i. When asked to select a template, chose whichever one suits, for example Team Site
Your new dedicated WSS Team Site farm as now been created, all that is needed it to connect it to the Portal
Configure the Portal to use the new Team Site Farm
Once the new WSS environment has been created, Self Service Site Creation must be enabled and the Portal used to create and manage the team sites needs to be informed of the location of the new environment.
a. Open SharePoint Central Administration - Start -> Administrative Tools -> SharePoint Central Administration
b. Click on the Configure Virtual Server Settings link
c. Click on the WSS link
d. Click on Configure Self-Service Site Creation
e. Ensure the option is set to On and then click OK
f. Open the Portal by browsing to http://portal/
g. Click on the Site Settings link
h. Click on the Change portal site properties and SharePoint site creation settings link
i. In the Location for Creating SharePoint Sites field enter:
http://WSS/_layouts/1033/scsignup.aspx
And click OK
Create a new Team Site
With the portal now configured to use the new dedicated Team Site environment, we can create a new Team Site.
a. Click on the Sites link
b. Click on the Create Site link
c. Enter a Title (eg. Demo Site), URL and Owner for the site and click OK
d. On the Add Link to Site screen, which adds the new site to the Site Registry, leave as default and click on OK
e. Select a Template and click OK
f. Verify that your new Team Site has been successfully created on the WSS virtual server
This is how you create a website and a child site.
There are five site groups in WSS
Guest - By default nothing
Reader - Use Self-Service Site Creation, View Pages, View Items,
Contributor - All rights included in the Reader site group, plus:Add Items, Add/Remove Private Web Parts, Browse Directories. Create Cross-Site Groups, Delete Items, Edit Items, Manage Personal Views, Update Personal Web Parts
Web Designer - All rights included in the Contributor site group, plus: Add and Customize Pages, Apply Themes and Borders, Apply Style Sheets, Cancel Check-out, Manage Lists
Administrator - All rights included in the Web Designer site group, plus: Create Subsites, Manage List Permissions, Manage Site Groups, View Usage DataData
For more information download administrator's userguidehttp://www.microsoft.com/downloads/details.aspx?FamilyID=a637eff6-8224-4b19-a6a4-3e33fa13d230&DisplayLang=en
Windows Sharepoint Service - 2
First we need the installer file. Here you downlaad the installer http://www.microsoft.com/windowsserver2003/technologies/sharepoint/default.mspx
It is just 34 MB
Check whether your machine meet the requirements
Windows 2003
.Net 1.1
IIS 6.0
Sql server 2000/MSDE
Double click on the downloded file STSV2.EXE.
This will cause Windows to decompress the file’s contents and to launch the installation program.
1. The Setup wizard appears, accept the license agreement and click Next to continue.
2. The next screen will ask you if you would like to perform a typical installation or if you would rather set up a server farm.
select the Typical Installation option and click Next.
3. The Setup program will now confirm that it is about to install the SharePoint Services and that the target drive has enough free space. Click the Install button to begin installing the necessary files.
4. As the installation progresses, you might notice a message indicating that Setup is configuring the Microsoft SQL Desktop Engine. The Windows SharePoint Services are dependant on SQL Server. As we all know though, SQL Server can be expensive. If you don’t have SQL Server installed on your server prior to installing the Windows SharePoint Services, Setup will automatically configure the SharePoint Services to use MSDE.
Once you the installtion is complete. Go to control panel>> administrative tools you will see the link to sharepoint adminstration. On double clicking you will see a page where you can create websites in sharepoint portal server and configuring them.
Tuesday, May 02, 2006
How are bit columns stored by the SQL Server?
1. Each field is stored as an 8-bit integer.
2. All bit columns are stored together in 8-bit(byte) groups.
3. Bit columns are stored the same as varbinary columns.
4. All bit columns are stored together in two contiguous bytes since SQL Server only allows 16 bit columns in a row. 5. Each bit column is stored in its respective place in the row as a single bit.
Answer:
2. Microsoft® SQL Server™ optimizes the storage used for bit columns. If there are 8 or fewer bit columns in a table, the columns are stored as 1 byte. If there are from 9 through 16 bit columns, they are stored as 2 bytes, and so on.
Thursday, April 27, 2006
Windows Sharepoint Service - 1
All these time we have traditional ways of sharing information through meetings, docs, assigning task, maintaining contacts, lists, lots of things, version controlling, and many more. Most of the things are available in content management systems. For version controlling we can go for some free tools like CVS and Microsoft Visual Sourcesafe. How to get everything in integrated. How to create sites and share information without programming knowledge. Yes everything is possible if you are ready click Next, Next , ....button (All are wizard). All the above the interfaces is in web. You can administer the site from anywhere in the network.
What is the history behind Sharepoint?
Initially it was started as Sharepoint team services - > STS in 2001
It was based on IIS arch. It was a stateful server. Very difficult to maintain web farm.
Customization was difficult. It was using ISAPI extensions and it was developed in ASP
What are the highlights of sharepoint?
Document sharing
Versioning
Web URL
Administration
Area, Topics
Personal sites
Audiences
SSO (single sign on)
Site search
Integration with biztalk
Indexing...... and many more
Is it licensed?
The basic version is absolutely free and it is just 34MB (Windows Sharepoint services) WSS. About 60% of SPS is made free through this.
and Sharepoint Portal service is a licensed.
What are the requirements?
Windows 2003
IIS 6
.Net 1.1
MSDE / Sql server
Tuesday, April 25, 2006
Hit a server side page through XMLHTTP...
Wanna hit a server side page without submitting the main page…
{
var pageUrl = url + "? + params;
var xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
xmlRequest.open("POST", pageUrl, false);
xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlRequest.send(null);
return xmlRequest;
}
var resText = xmlRequest.responseText;
try it out…
Thursday, February 16, 2006
Oracle from unbreakable to unpatchable
All because most people are not used to it does not mean you can claim it is unbreakable.
Courtesy: http://blogs.zdnet.com/Ou/?p=151&tag=nl.e622
Microsoft Office Live
Dont wait click the following link http://officelive.microsoft.com/
Sunday, February 05, 2006
Aspnet_wp.exe could not be started
Last week I had a problem, When I moved to new machine. I was able install everything except ASP.NET, Then I checked the status of Aspnet_wp.exe, it was not running. I re-installed whole asp.net using aspnet_regiis.exe. I was bored and started searching. Then i found, it was due to security in related folders.
WORKAROUND
To work around this problem, verify that the ASPNET account has the correct user rights as follows:
• %windir%\Microsoft.NET\Framework\Version\Temporary ASP.NET Files: Full Control
• %windir%\Temp: Full Control
• Application folder: Read
• %installroot% hierarchy (for example, %windir%\Microsoft.Net\Framework\Version): Read
• %windir%\Assembly: Read
Note This is the global assembly cache. You cannot directly use Windows Explorer to edit ACLs for this folder. Instead, open a command window, and then run the following command:
cacls %windir%\assembly /e /t /p domain\useraccount:RAlternatively, before you use Windows Explorer, run the following command to unregister Shfusion.dll:
regsvr32–u shfusion.dll
After you set user rights in Windows Explorer, run the following command to re-register Shfusion.dll:
regsvr32 shfusion.dll
• Web site root (for example, %root%\Inetpub\Wwwroot) or the path that the default Web site points to: Read
• %windir%\System32: Read (Typically, the ASPNET account has already been granted user rights as a member of the Users group.)
Courtesy : http://support.microsoft.com/default.aspx?kbid=811320
How to remove duplicate rows from a table in SQL Server
SUMMARY
Microsoft SQL Server tables should never contain duplicate rows, nor non-unique primary keys. For brevity, we will sometimes refer to primary keys as "key" or "PK" in this article, but this will always denote "primary key." Duplicate PKs are a violation of entity integrity, and should be disallowed in a relational system. SQL Server has various mechanisms for enforcing entity integrity, including indexes, UNIQUE constraints, PRIMARY KEY constraints, and triggers. Despite this, under unusual circumstances duplicate primary keys may occur, and if so they must be eliminated. One way they can occur is if duplicate PKs exist in non-relational data outside SQL Server, and the data is imported while PK uniqueness is not being enforced. Another way they can occur is through a database design error, such as not enforcing entity integrity on each table. Often duplicate PKs are noticed when you attempt to create a unique index, which will abort if duplicate keys are found.
This message is:
Msg 1505, Level 16, State 1 Create unique index aborted on duplicate key. If you are using SQL Server 2000 or SQL Server 2005, you may receive the following error message:
Msg 1505, Level 16, State 1 CREATE UNIQUE INDEX terminated because a duplicate key was found for object name '%.*ls' and index name '%.*ls'. The duplicate key value is %ls. This article discusses how to locate and remove duplicate primary keys from a table. However, you should closely examine the process which allowed the duplicates to happen in order to prevent a recurrence.
MORE INFORMATION
For this example, we will use the following table with duplicate PK values. In this table the primary key is the two columns (col1, col2). We cannot create a unique index or PRIMARY KEY constraint since two rows have duplicate PKs. This procedure illustrates how to identify and remove the duplicates.
create table t1(col1 int, col2 int, col3 char(50))insert into t1 values (1, 1, 'data value one')insert into t1 values (1, 1, 'data value one')insert into t1 values (1, 2, 'data value two')
The first step is to identify which rows have duplicate primary key values: SELECT col1, col2, count(*)FROM t1GROUP BY col1, col2HAVING count(*) < 1
This will return one row for each set of duplicate PK values in the table. The last column in this result is the number of duplicates for the particular PK value.
col1 col2
1 1 2
If there are only a few sets of duplicate PK values, the best procedure is to delete these manually on an individual basis. For example:
set rowcount 1delete from t1where col1=1 and col2=1
The rowcount value should be n-1 the number of duplicates for a given key value. In this example, there are 2 duplicates so rowcount is set to 1. The col1/col2 values are taken from the above GROUP BY query result. If the GROUP BY query returns multiple rows, the "set rowcount" query will have to be run once for each of these rows. Each time it is run, set rowcount to n-1 the number of duplicates of the particular PK value.
Before deleting the rows, you should verify that the entire row is duplicate. While unlikely, it is possible that the PK values are duplicate, yet the row as a whole is not. An example of this would be a table with Social Security Number as the primary key, and having two different people (or rows) with the same number, each having unique attributes. In such a case whatever malfunction caused the duplicate key may have also caused valid unique data to be placed in the row. This data should copied out and preserved for study and possible reconciliation prior to deleting the data.
If there are many distinct sets of duplicate PK values in the table, it may be too time-consuming to remove them individually. In this case the following procedure can be used:
1. First, run the above GROUP BY query to determine how many sets of duplicate PK values exist, and the count of duplicates for each set.
2. Select the duplicate key values into a holding table.
For example:SELECT col1, col2, col3=count(*)INTO holdkeyFROM t1GROUP BY col1, col2HAVING count(*) > 1
3. Select the duplicate rows into a holding table, eliminating duplicates in the process. For example:SELECT DISTINCT t1.*INTO holddupsFROM t1, holdkeyWHERE t1.col1 = holdkey.col1AND t1.col2 = holdkey.col2
4. At this point, the holddups table should have unique PKs, however, this will not be the case if t1 had duplicate PKs, yet unique rows (as in the SSN example above). Verify that each key in holddups is unique, and that you do not have duplicate keys, yet unique rows. If so, you must stop here and reconcile which of the rows you wish to keep for a given duplicate key value. For example, the query: S
ELECT col1, col2, count(*)FROM holddupsGROUP BY col1, col2
should return a count of 1 for each row. If yes, proceed to step 5 below. If no, you have duplicate keys, yet unique rows, and need to decide which rows to save. This will usually entail either discarding a row, or creating a new unique key value for this row. Take one of these two steps for each such duplicate PK in the holddups table.
5. Delete the duplicate rows from the original table.
For example:DELETE t1FROM t1, holdkeyWHERE t1.col1 = holdkey.col1AND t1.col2 = holdkey.col2 6. Put the unique rows back in the original table.
For example:INSERT t1 SELECT * FROM holddups
Courtesy:: http://support.microsoft.com/default.aspx?scid=kb;en-us;139444
Wednesday, February 01, 2006
Convert Julian Date to System.DateTime
private DateTime ConvertJulianToDateTime(double julianDate)
{
DateTime date;
double dblA, dblB, dblC, dblD, dblE, dblF;
double dblZ, dblW, dblX;
int day, month, year;
try
{
dblZ = Math.Floor(julianDate + 0.5);
dblW = Math.Floor((dblZ - 1867216.25) / 36524.25);
dblX = Math.Floor(dblW / 4);
dblA = dblZ + 1 + dblW - dblX;
dblB = dblA + 1524;
dblC = Math.Floor((dblB - 122.1) / 365.25);
dblD = Math.Floor(365.25 * dblC);
dblE = Math.Floor((dblB - dblD) / 30.6001);
dblF = Math.Floor(30.6001 * dblE);
day = Convert.ToInt32(dblB - dblD - dblF);
if (dblE > 13)
{
month = Convert.ToInt32(dblE - 13);
}
else
{
month = Convert.ToInt32(dblE - 1);
}
if ((month == 1) (month == 2))
{
year = Convert.ToInt32(dblC - 4715);
}
else
{
year = Convert.ToInt32(dblC - 4716);
}
date = new DateTime(year, month, day);
return date;
}
catch (ArgumentOutOfRangeException ex)
{
MessageBox.Show("Julian date could not be converted:\n" + ex.Message, "Conversion Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
date = new DateTime(0);
}
catch (Exception ex)
{
MessageBox.Show("Error converting Julian date:\n" +
ex.Message, "Conversion Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
date = new DateTime(0);
}
return date;
}
To learn more about about Julian dates, visit http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html
Saturday, January 07, 2006
Alternate to PDF
How to create MHTML?
Easy, Just pass the URL to this method
public static bool SaveWebPageToMHTFile( string url, string filePath)
{
bool result=false;
CDO.Message msg = new CDO.MessageClass();
ADODB.Stream stm=null ;
try
{
msg.MimeFormatted =true;
msg.CreateMHTMLBody(url,CDO.CdoMHTMLFlags.cdoSuppressNone, "" ,"" );
stm = msg.GetStream();
stm.SaveToFile(filePath,ADODB.SaveOptionsEnum.adSaveCreateOverWrite);
msg=null;
stm.Close();
result=true;
}
catch
{throw;}
finally
{
//cleanup here
}return result
Sunday, January 01, 2006
Free Modeling tool
For more information: www.gentleware.com
Saturday, December 24, 2005
Which is best ASP.Net or PHP
Comparing
ASP with MSSQL 2000
PHP 5 with MYSQL
ASP.Net with MSSQL 2000
For small applications
PHP is much faster than ASP.NET, beacuse PHP interprets all of its code inside the PHP program itself, and since it is not accessing any other outside sources like COM objects, etc. It can produce a page in about 1/8 the time as a ASP.NET page can.
For Large applications
ASP.Net with SQL server is much faster than PHP with MYSQL and PHP and Oracle. More over the source code written for ASP.Net can be ported to windows application with minimal changes, but it is not possible with PHP.
Writing code to connect retrive data from a table is much complex in ASP or ASP.Net when compared to PHP but, People developing ASP.Net through Visual Studio, it is as easy as button click.Though PHP has Cross-platform ability even from the beginning. .Net will soon get Cross-platform ability (Mono for Apache).
Applications develped in ASP.Net is much secure than PHP.
So ASP.Net is suitable for Enterpise appliactions and not to small appliactions.
For more imformation: http://www.oracle.com/technology/pub/articles/hull_asp.html
Friday, December 23, 2005
When Webservices Go Bad
They're great when they are available. Anywhere the user goes, the application is sure to follow. When they go away, as Salesforce.com did for its customers for several hours recently, the reason why client/server comes and goes becomes apparent.
18,700 customers of the hosted CRM service found themselves without application availability for over eight hours. Salesforce.com blamed a faulty database for the issue while repairing the service. A failover that is supposed to take place when this happens to keep the service running didn't happen.
In the report from Silicon.com, Salesforce apologized for the problem, and noted they have greater than 99 percent uptime. Some customers cited in the article disagreed, claiming monthly outages of an hour or longer occur regularly.
The problem comes down to infrastructure. A business has to have multiple instances of its web service available, lots of redundancy, to be able to stand behind claims of reliability.
Without that redundancy, web services can and do go away, especially as more users crowd into the system. Six Apart had that problem recently with its Typepad blogging service, a problem that persisted for months.
Web services may offer alternatives to PC-based applications, but until they reach a point of reliability greater than 99 percent, Microsoft doesn't have any reason to worry about its desktop businesses, especially Office.
Read this Article in a site. Just want to share it.
ASP.NET ATLAS
“Atlas” enables you to build applications with better performance than traditional Web applications in two key aspects — responsiveness and user interface (UI). Traditional Web applications require a round trip for updating data or controls, which can result in long waits. “Atlas”, on the other hand, dramatically improves application performance by reducing the need for round trips.
In addition, since “Atlas” performs much of the processing in the client, it enables you to build a richer UI giving users a superior user experience over traditional Web applications. Not only does “Atlas” give you the power to create all the controls and features users have come to expect from a rich UI (such as drag and drop, auto-completion, mouse hovering behavior, and more), but more importantly, it enables you to build interactive, data-bound controls that allow users to sort, update, or change their view of data with few or no round trips to the server.
While ASP.NET “Atlas” is both a new package of technologies and a new approach, it is consistent with the concept of developing applications using Asynchronous JavaScript and XML (AJAX). ”Atlas” applications are cross-platform and will run with little or no change in any modern browser. Examples of “Atlas” style applications include Microsoft's Virtual Earth site, Microsoft's Outlook Web Access e-mail client, and Start.com.
Creating AJAX-based Web applications is complex and requires extensive knowledge of client script. Thus, “Atlas” is not merely another implementation of AJAX. Instead, “Atlas” extends the AJAX concept in two significant ways. First, the “Atlas” client script libraries dramatically simplify the tasks of creating rich UIs and remote procedures calls by providing you with true object-oriented APIs and components for Atlas development. Second, “Atlas” extends the AJAX concept by providing a rich, integrated server development platform in ASP.NET 2.0. The “Atlas” server components include ASP.NET Web services and server controls that enable you to take advantage of the power of ASP.NET, such as the ASP.NET profiles service, in an “Atlas” application.
Overall, "Atlas" is about simplifying AJAX development and incorporating AJAX concepts into the typical Web application development process. The ASP.NET “Atlas” package of client and server-side development tools and components is a significant evolution and enhancement of the AJAX concept. The PDC materials — the Hands-On Labs, the “Atlas” QuickStart tutorials, and the keynote addresses — will help you to discover the power of the “Atlas” concept and its potential to transform the way you build Web applications.
To know more about ATLAS: http://www.asp.net/default.aspx?tabindex=7&tabid=47
Download Visual Studio Express Editions
Link : http://msdn.microsoft.com/vstudio/express/default.aspx
Monday, December 19, 2005
Prevent Sql Server Locks
Tables that change little, if at all, such as lookup tables consider altering the default lock level for the table.
You can override how SQL Server performs locking on a table by using the SP_INDEXOPTION command. Below is an example of code you can run to tell SQL Server to use page locking, not row locks, for a specific table:
SP_INDEXOPTION 'table_name', 'AllowRowLocks', FALSE
GO
SP_INDEXOPTION 'table_name', 'AllowPageLocks', FALSE
GO
This code turns off both row and page locking for the table, thus only table locking is available.
One way to help reduce locking issues is to identify those transactions that are taking a long time to run. The longer they take to run, the longer their locks will block other processes, causing contention and reduce performance. The following script can be run to identify current, long-running transactions. This will provide you with a clue as to what transactions are taking a long time, allowing you to investigate and resolve the cause.
SELECT spid, cmd, status, loginame, open_tran, datediff(s, last_batch, getdate ()) AS [WaitTime(s)]FROM master..sysprocesses pWHERE open_tran > 0AND spid > 50AND datediff (s, last_batch, getdate ()) > 30ANd EXISTS (SELECT * FROM master..syslockinfo l WHERE req_spid = p.spid AND rsc_type <> 2)
This query provides results based on the instant is runs, and will vary each time you run it. The goal is to review the results and look for transactions that have been open a long time. This generally indicates some problem that should be investigated.
In order to reduce blocking locks in an application, you must first identify them.
Once they are identified, you can then evaluate what is going on, and perhaps be able to take the necessary action to prevent them. The following script can be run to identify processes that have blocking locks that occur longer than a time you specify. You can set the value used to identify blocking locks to any value you want. In the example below, it is for 10 seconds.
SELECT spid, waittime, lastwaittype, waitresourceFROM master..sysprocessesWHERE waittime > 10000 -- The wait time is measured in millisecondsAND spid > 50 -- Use > 50 for SQL Server 2000, use > 12 for SQL Server 7.0
This query measures blocking locks in real-time, which means that only if there is a blocking lock fitting your time criteria when you this query will you get any results. If you like, you can add some additional code that will loop through the above code periodically in order to more easily identify locking issues. Or, you can just run the above code during times when you think that locking is a problem.
The original link is http://www.sql-server-performance.com/reducing_locks.asp
Tuesday, December 13, 2005
.Net Interview questions
.Net
ASP.NET
Winforms
Remoting
Framework Faq
C# and VB.Net
