<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6327673815580642833</id><updated>2012-01-22T07:12:09.633-08:00</updated><category term='C#'/><category term='Windows XP'/><category term='Publishing precompiled'/><category term='Excel to SQL'/><category term='ASP.NET 2.0'/><category term='Applies ASP.NET'/><category term='SQL Bulk Copy'/><category term='Precompiled'/><category term='MSSQL Server Express'/><category term='web.config'/><title type='text'>Technology Synapse</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://techsynapse.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6327673815580642833/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://techsynapse.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Arun Kumar</name><uri>http://www.blogger.com/profile/18192345302829265261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6327673815580642833.post-4388765195662541406</id><published>2009-12-24T00:35:00.000-08:00</published><updated>2009-12-24T01:23:26.336-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='web.config'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.NET 2.0'/><category scheme='http://www.blogger.com/atom/ns#' term='Publishing precompiled'/><category scheme='http://www.blogger.com/atom/ns#' term='Precompiled'/><category scheme='http://www.blogger.com/atom/ns#' term='Applies ASP.NET'/><title type='text'>[No relevant source lines]:Compiler Error Message: CS0433</title><content type='html'>Hi, Sorry again for a long communication gap. I was indulged into many things other than programming. Last week I came across the "Compiler Error Message: CS0433", "[No relevant source lines]". I was on vacation at my village without access to the internet when one of my friends told me about the error. I got the feel that the the specified error can be due to duplicate assemblies. I asked further about the hosting parameters and environment, he told me that initially they had precompiled deployment and now it's with the source.&lt;br /&gt;&lt;br /&gt;If you have 2 assemblies (ddl files) within the same web application bin folder named _Default. This could happen if another ddl had a web page named default.aspx whose codebehind was compiled in that ddl but you (or someone else) replaced the default.aspx whose codebehind was in another assembly.&lt;br /&gt;&lt;br /&gt;So the error is due to version conflict of dlls. Clean the bin folder old version of dlls.&lt;br /&gt;&lt;br /&gt;My friend removed the bin folder and recompiled the solution and then published. The error disappeared.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6327673815580642833-4388765195662541406?l=techsynapse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techsynapse.blogspot.com/feeds/4388765195662541406/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6327673815580642833&amp;postID=4388765195662541406' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6327673815580642833/posts/default/4388765195662541406'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6327673815580642833/posts/default/4388765195662541406'/><link rel='alternate' type='text/html' href='http://techsynapse.blogspot.com/2009/12/no-relevant-source-linescompiler-error.html' title='[No relevant source lines]:Compiler Error Message: CS0433'/><author><name>Arun Kumar</name><uri>http://www.blogger.com/profile/18192345302829265261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6327673815580642833.post-3560895112847479726</id><published>2009-07-08T04:33:00.000-07:00</published><updated>2009-07-08T04:45:02.137-07:00</updated><title type='text'>Running 32 bit .net application on 64 bit operating system</title><content type='html'>IIS 6.0 supports both the 32-bit mode and the 64-bit mode. However IIS 6.0 does not support running both modes at the same time on a 64-bit version of Windows. ASP.NET 1.1 runs only in 32-bit mode. ASP.NET 2.0 runs in 32-bit mode or in 64-bit mode. Therefore, if you want to run ASP.NET 1.1 and ASP.NET 2.0 at the same time, you must run IIS in 32-bit mode.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ASP.NET 1.1, 32-bit version&lt;br /&gt;To run the 32-bit version of ASP.NET 1.1, follow these steps:&lt;br /&gt;1. Click Start, click Run, type cmd, and then click OK. &lt;br /&gt;2. Type the following command to enable the 32-bit mode:&lt;br /&gt;cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1 &lt;br /&gt;3. Type the following command to install the version of ASP.NET 1.1 and to install the script maps at the IIS root and under:&lt;br /&gt;%SYSTEMROOT%\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -i  &lt;br /&gt;4. Make sure that the status of ASP.NET version 1.1.4322 is set to Allowed in the Web service extension list in Internet Information Services Manager. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ASP.NET 2.0, 32-bit version&lt;br /&gt;To run the 32-bit version of ASP.NET 2.0, follow these steps:1. Click Start, click Run, type cmd, and then click OK. &lt;br /&gt;2. Type the following command to enable the 32-bit mode:&lt;br /&gt;cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1 &lt;br /&gt;3. Type the following command to install the version of ASP.NET 2.0 (32-bit) and to install the script maps at the IIS root and under:&lt;br /&gt;%SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i  &lt;br /&gt;4. Make sure that the status of ASP.NET version 2.0.50727 (32-bit) is set to Allowed in the Web service extension list in Internet Information Services Manager. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ASP.NET 2.0, 64-bit version&lt;br /&gt;To run the 64-bit version of ASP.NET 2.0, follow these steps:1. Click Start, click Run, type cmd, and then click OK. &lt;br /&gt;2. Type the following command to disable the 32-bit mode:&lt;br /&gt;cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 0 &lt;br /&gt;3. Type the following command to install the version of ASP.NET 2.0 and to install the script maps at the IIS root and under:&lt;br /&gt;%SYSTEMROOT%\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis.exe -i  &lt;br /&gt;4. Make sure that the status of ASP.NET version 2.0.50727 is set to Allowed in the Web service extension list in Internet Information Services Manager. &lt;br /&gt;Note The build version of ASP.NET 2.0 may differ depending on what the currently released build version is. These steps are for build version 2.0.50727.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6327673815580642833-3560895112847479726?l=techsynapse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techsynapse.blogspot.com/feeds/3560895112847479726/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6327673815580642833&amp;postID=3560895112847479726' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6327673815580642833/posts/default/3560895112847479726'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6327673815580642833/posts/default/3560895112847479726'/><link rel='alternate' type='text/html' href='http://techsynapse.blogspot.com/2009/07/running-32-bit-net-application-on-64.html' title='Running 32 bit .net application on 64 bit operating system'/><author><name>Arun Kumar</name><uri>http://www.blogger.com/profile/18192345302829265261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6327673815580642833.post-5821118993009851214</id><published>2008-03-20T06:29:00.000-07:00</published><updated>2008-03-20T06:42:35.367-07:00</updated><title type='text'>Hey I am Back!</title><content type='html'>Sorry for a long communication gap. I was busy on a project based on GIS and Intelligence (a project other than ASP.NET technologies). It was quite challenging  for me because it was a new experience at all. I'll discuss it later and will be taking the previous misson forward. Again I apolozise for inconvience.&lt;br /&gt;Cheers!&lt;br /&gt;Arun&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6327673815580642833-5821118993009851214?l=techsynapse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techsynapse.blogspot.com/feeds/5821118993009851214/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6327673815580642833&amp;postID=5821118993009851214' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6327673815580642833/posts/default/5821118993009851214'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6327673815580642833/posts/default/5821118993009851214'/><link rel='alternate' type='text/html' href='http://techsynapse.blogspot.com/2008/03/hey-i-am-back.html' title='Hey I am Back!'/><author><name>Arun Kumar</name><uri>http://www.blogger.com/profile/18192345302829265261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6327673815580642833.post-8424753485654986027</id><published>2007-04-25T07:57:00.000-07:00</published><updated>2007-04-26T03:25:24.937-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Bulk Copy'/><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Applies ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Excel to SQL'/><title type='text'>Loading excel sheet (Workbook) data to SQL database using ASP.NET C#</title><content type='html'>&lt;a href="http://bp0.blogger.com/_pWSIMU8FQBY/RjB7vSrpG-I/AAAAAAAAAAU/ebzaJ-kJUJs/s1600-h/img1.JPG"&gt;&lt;/a&gt;&lt;div&gt;&lt;div&gt;This will describe about loading data from excel sheet (workbook) to SQL database from an asp.net application. It will also provide solutions to all the queries related to exporting excel to SQL, using bulk copy, loading excel data to SQL database etc.&lt;br /&gt;&lt;br /&gt;There are many ways to load excel sheet (workbook) data to SQL database. Here I am describing about using bulk copy and data reader. Before proceeding further I would like to mention that we need to insert (define) name to rows and columns of excel sheet that contains the actual data. The first row will be treated as names of columns and rest as data. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;img id="BLOGGER_PHOTO_ID_5057678704518962162" style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://bp3.blogger.com/_pWSIMU8FQBY/RjB7_CrpG_I/AAAAAAAAAAc/-Ubq4G9qjdE/s320/img2.JPG" border="0" /&gt;&lt;br /&gt;Now loading excel sheet (workbook) data to SQL database using C#. Let we have Book1.xls excel file that has our data and we need to load this data to tbl_Emp_details table of our SQL database. Let the excel sheet has five columns i.e. name, sex, age, address and qualification. Also our SQL database has same columns along with ID column (primary key). Please note that if you are using bulk copy command then the column sequence of excel sheet and SQL data table must be same. If you are using primary key column (Identity column) then make this column the last column of the table because the bulk copy client will insert first column data of data reader into the first column of SQL data table and so on. If you have defined the first column as Identity column (primary key) then the data of first column of excel sheet will be skipped and the data of remaining columns will be inserted in the sequence of data reader columns. Before loading the excel file data do these things:&lt;br /&gt;&lt;br /&gt;&lt;em&gt;1. Select all rows and columns of excel sheet and click on ‘Insert’ menu and select ‘Names’ then ‘Define’.&lt;br /&gt;2. In the popup window define (type) name of table (e.g. myExcelTable) in ‘Names in workBook’ and click ‘OK’.&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;We define name (Insere Name) is because the selected rows and columns will be treated as a table and we can execute select command on it. Now the defined name will be the name of the table and the first row of excel sheet will be treated as the names of columns and remaining rows as data. If you do not define name then you will get the error as “The Microsoft Jet database engine could not find the object 'myExcelTable'. Make sure the object exists and that you spell its name and the path name correctly.”&lt;br /&gt;&lt;br /&gt;Define connection string in webconfig file for SQL database (In example it is for express database)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;color:#3333ff;"&gt;&amp;lt;&lt;span style="color:#cc0000;"&gt;connectionStrings&lt;/span&gt;&amp;gt; &amp;lt;&lt;span style="color:#cc0000;"&gt;add&lt;/span&gt; &lt;span style="color:#ff6666;"&gt;name&lt;/span&gt;="ConnectionString" &lt;span style="color:#ff6666;"&gt;connectionString&lt;/span&gt;="Data Source=.\SQLEXPRESS;AttachDbFilename=DataDirectory\ASPNETDB.MDF;Integrated Security=True;User Instance=True" &lt;span style="color:#ff6666;"&gt;providerName&lt;/span&gt;="System.Data.SqlClient" /&amp;gt; &amp;lt;/&lt;span style="color:#cc0000;"&gt;connectionStrings&lt;/span&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Now add references of Oledb and SqlClient to the code behind file.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#3333ff;"&gt;using&lt;/span&gt; System.Data.OleDb;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;span style="color:#3333ff;"&gt;using&lt;/span&gt; System.Data.SqlClient;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now define a string variable to store connection string for Oledb connection and assign it the proper string. Define another string variable and assign sql connection string (connection string defined in webconfig file) to it. Now initialize a new Oledb connection using Oledb Connection string and open it. Define Oledb command and initialize it with select command. The table name in select command will be the name that we had defined (Inserted) by selecting rows and columns of excel sheet. Note: First row of excel sheet will be treated as the names of columns and we will select these columns only in our select command.&lt;br /&gt;Now using data reader and bulk copy command we will insert data into SQL database.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#009900;"&gt;//drive conniction string from webconfig file&lt;/span&gt;&lt;br /&gt;string SQLconnStr = &lt;span style="color:#00cccc;"&gt;ConfigurationManager&lt;/span&gt;.ConnectionStrings[&lt;span style="color:#cc0000;"&gt;"ConnectionString"&lt;/span&gt;].ToString();&lt;br /&gt;&lt;span style="color:#009900;"&gt;//define connectionstring and excel file name for Oledb database engine&lt;/span&gt;&lt;br /&gt;string OledbConStr = &lt;span style="color:#cc0000;"&gt;"Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=c:/Book1.xls;" + "Extended Properties=Excel 8.0;"&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:#009900;"&gt;//Oledb connection&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#00cccc;"&gt;OleDbConnection&lt;/span&gt; myOLEDBConn = &lt;span style="color:#3333ff;"&gt;new&lt;/span&gt; &lt;span style="color:#00cccc;"&gt;OleDbConnection&lt;/span&gt;(OledbConStr);&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;try &lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;myOLEDBConn.Open();&lt;br /&gt;&lt;span style="color:#009900;"&gt;//select data (rows) from excel sheet (workbook)&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#00cccc;"&gt;OleDbCommand&lt;/span&gt; myOLEDBCmnd = &lt;span style="color:#3333ff;"&gt;new&lt;/span&gt; &lt;span style="color:#00cccc;"&gt;OleDbCommand&lt;/span&gt;(&lt;span style="color:#cc0000;"&gt;"select name, sex, age, address, qualification from myExcelTable"&lt;/span&gt;, myOLEDBConn);&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;using&lt;/span&gt; (&lt;span style="color:#00cccc;"&gt;OleDbDataReader&lt;/span&gt; dbRdr = myOLEDBCmnd.ExecuteReader())&lt;br /&gt;{&lt;br /&gt;&lt;span style="color:#009900;"&gt;//save to sql database&lt;/span&gt;&lt;br /&gt;using (&lt;span style="color:#00cccc;"&gt;SqlBulkCopy&lt;/span&gt; mysqlblkcpy = &lt;span style="color:#3333ff;"&gt;new&lt;/span&gt; &lt;span style="color:#00cccc;"&gt;SqlBulkCopy&lt;/span&gt;(SQLconnStr))&lt;br /&gt;{&lt;br /&gt;&lt;span style="color:#009900;"&gt;//define destination table name&lt;/span&gt;&lt;br /&gt;mysqlblkcpy.DestinationTableName = &lt;span style="color:#cc0000;"&gt;"tbl_Emp_Details"&lt;/span&gt;;&lt;br /&gt;&lt;span style="color:#009900;"&gt;//define batch size in order to make operation easy&lt;/span&gt;&lt;br /&gt;mysqlblkcpy.BatchSize = 500;&lt;br /&gt;mysqlblkcpy.WriteToServer(dbRdr);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;catch&lt;/span&gt; (&lt;span style="color:#00cccc;"&gt;Exception&lt;/span&gt; ex)&lt;br /&gt;{&lt;br /&gt;Response.Write(ex.Message.ToString());&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If we want more reliable method to load excel data to SQL database then we should use simple insert command instead of bulk copy command.&lt;br /&gt;&lt;br /&gt;Note: If you receive the error: "&lt;strong&gt;Could not find installable ISAM&lt;/strong&gt;." It means that your Oledb Connection string is not correct. Either you have misspell something or&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;color:#cc0000;"&gt;Extended Properties=Excel 8.0;&lt;/span&gt; version is incorrect. Try the version 11.0 in place of 8.0 or correct spellings.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6327673815580642833-8424753485654986027?l=techsynapse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techsynapse.blogspot.com/feeds/8424753485654986027/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6327673815580642833&amp;postID=8424753485654986027' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6327673815580642833/posts/default/8424753485654986027'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6327673815580642833/posts/default/8424753485654986027'/><link rel='alternate' type='text/html' href='http://techsynapse.blogspot.com/2007/04/loading-excel-sheet-workbook-data-to.html' title='Loading excel sheet (Workbook) data to SQL database using ASP.NET C#'/><author><name>Arun Kumar</name><uri>http://www.blogger.com/profile/18192345302829265261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp3.blogger.com/_pWSIMU8FQBY/RjB7_CrpG_I/AAAAAAAAAAc/-Ubq4G9qjdE/s72-c/img2.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6327673815580642833.post-1783180885959127493</id><published>2007-04-25T05:37:00.000-07:00</published><updated>2007-04-25T21:53:57.920-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MSSQL Server Express'/><category scheme='http://www.blogger.com/atom/ns#' term='Applies ASP.NET'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows XP'/><title type='text'>What to do when error like “ System.Data.SqlClient.SqlException: Failed to update database "C:\....\ASPNETDB.MDF" because the database is read-only"</title><content type='html'>&lt;p&gt;&lt;em&gt;What to do when error comes like “Exception Details: System.Data.SqlClient.SqlException: Failed to update database "C:\INETPUB\WWWROOT\....\APP_DATA\ASPNETDB.MDF" because the database is read-only”&lt;br /&gt;or&lt;br /&gt;“Exception Details: System.Data.SqlClient.SqlException: Failed to save to database "C:\INETPUB\WWWROOT\....\APP_DATA\ASPNETDB.MDF" because the database is read-only”&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;“Database is read-only” types of errors are common errors encountered when hosting the website on IIS with MS SQL Express database. These types of errors may occur when you have the NTFS file system and ASPNET user account does not have proper access permissions. If you do not provide write permissions to ASPNET user account to the hosted directory this error will occur. Simply add ASPNET user account to permission list to the directory and assign write permissions to this account. There are many ways to assign permissions and overcome this problem.&lt;br /&gt;&lt;br /&gt;First do not host (place) your website to wwwroot directory. Either save it to the root of primary drive (C:\) or host it some where else because sometimes default access permissions do not provide ASPNET user account the write permissions. If you are hosting your website to wwwroot directory then make sure that ASPNET user account has write permission to App_Data Directory or .MDF file. You can check this by right clicking on App_Data directory and then selecting security tab. If you are able to see ASPNET user account in “Group or user names” then click on it and make sure that ‘write check box’ is checked (selected) in “permissions for ASPNET”. If it is not checked (selected) then check(select) it. If you do not find ASPNET user account into “Groups or user names” then add it and give it write permissions.&lt;br /&gt;&lt;br /&gt;Second if you are hosting your website to any directory other than wwwroot then give ASPNET user account write permissions to website directory or App_Data directory as follow:&lt;br /&gt;&lt;br /&gt;&lt;em&gt;1. Right clicking on App_Data directory and then selecting security tab.&lt;br /&gt;2. If you are able to see ASPNET user account in “Group or user names” then click on it and make sure that ‘write check box’ is checked (selected) in “permissions for ASPNET”. If it is not checked (selected) then check(select) it.&lt;br /&gt;3. If you ado not find ASPNET user account into “Groups or user names” then click on ‘Add’.&lt;br /&gt;4. In ‘Select Users or Groups’ windows click on ‘Advance’.&lt;br /&gt;5. Now click on ‘Find Now’.&lt;br /&gt;6. Here you will see the list of users. Now select ASPNET and click on ‘Ok’ to close third window and click again on ‘Ok’ to close second window (Select Users or Group).&lt;br /&gt;7. Now click on ASPNET user account and check (select) write check box and click on ‘Apply’ and then ‘Ok’.&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;Now you have enough permission to your ASPNET user account to write or update Express Database. You can run your website now.&lt;br /&gt;&lt;br /&gt;Third, you can place your website in shared folder but the access (write) permissions to ASPNET user account are required.&lt;br /&gt;&lt;br /&gt;Thus you can overcome these types of errors.&lt;br /&gt;If you still have problem, Please feel free to seek help.&lt;br /&gt;&lt;br /&gt;To turn on the security tab in folder properties please follow the process:&lt;br /&gt;&lt;br /&gt;&lt;em&gt;. Click 'Tools' menu of explorer and select 'Folder Options'&lt;br /&gt;. Select 'View' tab and uncheck (remove) the option 'Use simple file sharing (Recommended)' from the 'Advanced Options'. This option is the last in the list.&lt;/em&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6327673815580642833-1783180885959127493?l=techsynapse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techsynapse.blogspot.com/feeds/1783180885959127493/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6327673815580642833&amp;postID=1783180885959127493' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6327673815580642833/posts/default/1783180885959127493'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6327673815580642833/posts/default/1783180885959127493'/><link rel='alternate' type='text/html' href='http://techsynapse.blogspot.com/2007/04/what-to-do-when-error-like.html' title='What to do when error like “ System.Data.SqlClient.SqlException: Failed to update database &quot;C:\....\ASPNETDB.MDF&quot; because the database is read-only&quot;'/><author><name>Arun Kumar</name><uri>http://www.blogger.com/profile/18192345302829265261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6327673815580642833.post-8047819099570175853</id><published>2007-03-15T01:19:00.000-07:00</published><updated>2007-08-27T09:21:28.734-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#'/><category scheme='http://www.blogger.com/atom/ns#' term='Applies ASP.NET'/><title type='text'>Generating word document dynamically with header, footer and page border using ASP.NET (c#)</title><content type='html'>&lt;div align="justify"&gt;Since Microsoft Word has good support for HTML, you can generate word document (customized) from your asp.net application very easily. First define a string type variable, strDocBody, which will contain the body of word document. Now add the page HTML to strDocBody as follow: &lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-size:0;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div align="justify"&gt;&lt;span style="font-size:0;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-size:0;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-size:0;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-size:78%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-size:0;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-size:0;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="justify"&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;strDocBody = &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="color:#cc0000;"&gt;"&amp;lt;!-- /* Page HTML or WordML */&amp;gt;&amp;lt;html " +&lt;br /&gt;"xmlns:o='urn:schemas-microsoft-com:office:office' " +&lt;br /&gt;"xmlns:w='urn:schemas-microsoft-com:office:word'" +&lt;br /&gt;"xmlns='http://www.w3.org/TR/REC-html40'&amp;gt;" +&lt;br /&gt;"&amp;lt;head&amp;gt;" +&lt;br /&gt;"&amp;lt;title&amp;gt;Dynamic Generated Document&amp;lt;/title&amp;gt;"&lt;/span&gt;;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;This will define xmlns properties (standreds) and title of document. Now set the document properties like layout view, zoom etc.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;strDocBody = strDocBody + &lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;color:#cc0000;"&gt;"&amp;lt;!-- /* Page layout(view) Definitions */&amp;gt;" +&lt;br /&gt;"&amp;lt;!--[if gte mso 9]&amp;gt;" +&lt;br /&gt;"&amp;lt;xml&amp;gt;" +&lt;br /&gt;"&amp;lt;w:WordDocument&amp;gt;" +&lt;br /&gt;"&amp;lt;w:View&amp;gt;Print&amp;lt;/w:View&amp;gt;" +&lt;br /&gt;"&amp;lt;w:Zoom&amp;gt;100&amp;lt;/w:Zoom&amp;gt;" +&lt;br /&gt;"&amp;lt;w:DoNotOptimizeForBrowser/&amp;gt;" +&lt;br /&gt;"&amp;lt;/w:WordDocument&amp;gt;" +&lt;br /&gt;"&amp;lt;/xml&amp;gt;" +&lt;br /&gt;"&amp;lt;![endif]&amp;gt;";&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Here &lt;span style="font-family:courier new;font-size:85%;color:#cc0000;"&gt;"&amp;lt;w:View&amp;gt;Print&amp;lt;/w:View&amp;gt;"&lt;/span&gt; represents the Print Layout View and &lt;span style="font-family:courier new;font-size:85%;color:#cc0000;"&gt;"&amp;lt;w:Zoom&amp;gt;100&amp;lt;/w:Zoom&amp;gt;"&lt;/span&gt; represents the page zoom. Now add the style section. This section will contain the page style properties like page size, header id, footer id, page border, margins, font family etc.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;color:#cc0000;"&gt;&lt;span style="color:#000000;"&gt;strDocBody = strDocBody&lt;/span&gt; +"&amp;lt;!-- /* Page Style Definitions */&amp;gt;" +&lt;br /&gt;"&amp;lt;style&amp;gt; @page Section1 " +&lt;br /&gt;" {size:8.5in 11.0in; mso-first-footer:ff1; mso-footer: f1; mso-header: h1; border:solid navy 2.25pt; padding:24.0pt 24.0pt 24.0pt 24.0pt; " +&lt;br /&gt;"margin:0.75in 0.50in 0.75in 0.50in ; " +&lt;br /&gt;"mso-header-margin:.5in; " +&lt;br /&gt;"mso-footer-margin:.5in; mso-paper-source:0;}" +&lt;br /&gt;"div.Section1" +&lt;br /&gt;" {page:Section1;}" + "p.MsoFooter, li.MsoFooter, div.MsoFooter{margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-size:12.0pt; font-family:'Arial';}" +&lt;br /&gt;"p.MsoHeader, li.MsoHeader, div.MsoHeader {margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-size:12.0pt; font-family:'Arial';}" +&lt;br /&gt;"--&amp;gt;" +&lt;br /&gt;"&amp;lt;/style&amp;gt;" +&lt;br /&gt;"&amp;lt;/head&amp;gt;";&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The size of page is defined as &lt;span style="font-family:courier new;font-size:85%;color:#cc0000;"&gt;size:8.5in 11.0in;&lt;/span&gt; and &lt;span style="font-family:courier new;font-size:85%;color:#cc0000;"&gt;mso-first-footer:ff1;&lt;/span&gt; defines the first page footer if you select the option &lt;strong&gt;Different first page&lt;/strong&gt; from menu &lt;strong&gt;File &amp;gt; Page Setup &amp;gt; Layout&lt;/strong&gt; tab. &lt;span style="font-family:courier new;font-size:85%;color:#cc0000;"&gt;mso-footer: f1;&lt;/span&gt; defines footer for all pages. The same way you can define first page header and header for all pages as &lt;span style="font-family:courier new;font-size:85%;color:#cc0000;"&gt;mso-header: h1;.&lt;/span&gt; Other header and footer properties are defined in MsoFooter, MsoHeaderer classes as shown in sample code. &lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;span style="color:#990000;"&gt;border:solid navy 2.25pt;&lt;/span&gt;&lt;/span&gt; defines the &lt;strong&gt;page border&lt;/strong&gt; and &lt;span style="font-family:courier new;font-size:85%;color:#990000;"&gt;padding:24.0pt 24.0pt 24.0pt 24.0pt;&lt;/span&gt; defines page border position.&lt;br /&gt;Now add the actual body of the document and header and footer.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;strDocBody = strDocBody + &lt;span style="color:#cc0000;"&gt;"&amp;lt;!-- /* Actual document body */&amp;gt;" +&lt;br /&gt;"&amp;lt;body lang=EN-US style='tab-interval:.5in'&amp;gt;" +&lt;br /&gt;"&amp;lt;div class=Section1&amp;gt;" +&lt;br /&gt;"&amp;lt;h1&amp;gt;This is my Heading&amp;lt;/h1&amp;gt;" +&lt;br /&gt;"&amp;lt;h2&amp;gt;This is my Sub Heading&amp;lt;/h2&amp;gt;" +&lt;br /&gt;"&amp;lt;p style='color:navy;'&amp;gt; This is blue text&amp;lt;/p&amp;gt;" +&lt;br /&gt;"&amp;lt;p style='font-weight:bold; color:green;'&amp;gt;&amp;lt;u&amp;gt; This is green bold underlined text &amp;lt;/u&amp;gt;&amp;lt;/p&amp;gt;" +&lt;br /&gt;"&amp;lt;p style='color:red'&amp;gt;&amp;lt;I&amp;gt;" +&lt;br /&gt;DateTime.Now + "&amp;lt;/I&amp;gt;&amp;lt;/p&amp;gt;" +&lt;br /&gt;//my image&lt;br /&gt;"&amp;lt;img img width=217 height=162 id='myImg' src='C:/WINDOWS/Web/Wallpaper/Autumn.jpg'&amp;gt;" ;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;strDocBody = strDocBody + &lt;span style="color:#cc0000;"&gt;"&amp;lt;!-- /* Header and footer */&amp;gt;" +&lt;br /&gt;"&amp;lt;!--[if supportFields]&amp;gt;" +&lt;br /&gt;"&amp;lt;div style='mso-element:header' id=h1&amp;gt;&amp;lt;p class=MsoHeader&amp;gt;&amp;lt;span style='mso-tab-count:4'&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style='mso-field-code: PAGE '&amp;gt;&amp;lt;/span&amp;gt; &amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;" +&lt;br /&gt;"&amp;lt;div style='mso-element:footer' id=f1&amp;gt; " +&lt;br /&gt;"&amp;lt;p class=MsoFooter style='border:none;mso-border-bottom-alt:solid windowtext .75pt;padding:0in;mso-padding-alt:0in 0in 1.0pt 0in'&amp;lt;/p&amp;gt; " +&lt;br /&gt;"Page &amp;lt;span style='mso-field-code: PAGE '&amp;gt;&amp;lt;span style='mso-no-proof:yes'&amp;gt;1&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt; " +&lt;br /&gt;" &amp;lt;span style='mso-tab-count: 14'&amp;gt; &amp;lt;span style='mso-field-code:&lt;br /&gt;NUMPAGES '&amp;gt;&amp;lt;/span&amp;gt; " +&lt;br /&gt;" &amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;![endif]--&amp;gt;" +&lt;br /&gt;"&amp;lt;/div&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;";&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;Now force this content to be downloaded as your word document using response.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;span style="color:#009900;"&gt;//Force this content to be downloaded as a Word document&lt;/span&gt;&lt;br /&gt;Response.AddHeader(&lt;span style="color:#cc0000;"&gt;"Content-Type", "application/msword"&lt;/span&gt;);&lt;br /&gt;&lt;span style="color:#009900;"&gt;//filename specify the name of word document of your choice&lt;/span&gt;&lt;br /&gt;Response.AddHeader(&lt;span style="color:#cc0000;"&gt;"Content-disposition", "attachment; filename=myWordDoc.doc"&lt;/span&gt;);&lt;br /&gt;Response.Charset = &lt;span style="color:#cc0000;"&gt;""&lt;/span&gt;;&lt;br /&gt;Response.Write(strDocBody); &lt;/span&gt;&lt;/div&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;p&gt;&lt;br /&gt;&lt;/span&gt;Add the whole content on page load event or button click event as example code.&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;span style="color:#3333ff;"&gt;protected void&lt;/span&gt; Page_Load(&lt;span style="color:#3333ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#00cccc;"&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;{&lt;br /&gt;&lt;span style="color:#3333ff;"&gt;&lt;span style="color:#cc0000;"&gt;&lt;span style="color:#3333ff;"&gt;string&lt;/span&gt; &lt;span style="color:#000000;"&gt;strDocBody;&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;span style="color:#3333ff;"&gt;&lt;span style="color:#cc0000;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;span style="color:#3333ff;"&gt;&lt;span style="color:#cc0000;"&gt;&lt;span style="color:#3333ff;"&gt;try&lt;/span&gt;&lt;span style="color:#000000;"&gt; { &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;span style="color:#3333ff;"&gt;&lt;span style="color:#cc0000;"&gt;&lt;span style="color:#000000;"&gt;strDocBody =&lt;/span&gt; "&amp;lt;html " &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "xmlns:o='urn:schemas-microsoft-com:office:office' " &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "xmlns:w='urn:schemas-microsoft-com:office:word'" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "xmlns='http://www.w3.org/TR/REC-html40'&amp;gt;" &lt;span style="color:#000000;"&gt;+ &lt;/span&gt;"&amp;lt;head&amp;gt;" &lt;span style="color:#000000;"&gt;+ &lt;/span&gt;"&amp;lt;title&amp;gt;Dynamic Generated Document&amp;lt;/title&amp;gt;"&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;span style="color:#3333ff;"&gt;&lt;span style="color:#cc0000;"&gt;&lt;span style="color:#000000;"&gt;strDocBody = strDocBody +&lt;/span&gt; "&amp;lt;!--[if gte mso 9]&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;xml&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;w:WordDocument&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;w:View&amp;gt;Print&amp;lt;/w:View&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;w:Zoom&amp;gt;100&amp;lt;/w:Zoom&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;w:DoNotOptimizeForBrowser/&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;/w:WordDocument&amp;gt;"&lt;span style="color:#000000;"&gt; +&lt;/span&gt; "&amp;lt;/xml&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;![endif]--&amp;gt;"&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;span style="color:#3333ff;"&gt;&lt;span style="color:#cc0000;"&gt;&lt;span style="color:#000000;"&gt;strDocBody = strDocBody +&lt;/span&gt; "&amp;lt;style&amp;gt; @page" &lt;span style="color:#000000;"&gt;+ &lt;/span&gt;"{size:8.5in 11.0in; mso-first-footer:ff1; mso-footer: f1; mso-header: h1; border:solid navy 2.25pt; padding:24.0pt 24.0pt 24.0pt 24.0pt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; " margin:0.75in 0.50in 0.75in 0.50in ; " &lt;span style="color:#000000;"&gt;+&lt;/span&gt; " mso-header-margin:.5in; " &lt;span style="color:#000000;"&gt;+&lt;/span&gt; " mso-footer-margin:.5in; mso-paper-source:0;}" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; " div.Section1" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; " {page:Section1;}" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "p.MsoFooter, li.MsoFooter, div.MsoFooter{margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-size:12.0pt; font-family:'Arial';}" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "p.MsoHeader, li.MsoHeader, div.MsoHeader {margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-size:12.0pt; font-family:'Arial';}" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "--&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;/style&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;/head&amp;gt;"&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;span style="color:#3333ff;"&gt;&lt;span style="color:#cc0000;"&gt;&lt;span style="color:#000000;"&gt;strDocBody = strDocBody +&lt;/span&gt; "&amp;lt;body lang=EN-US style='tab-interval:.5in'&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;div class=Section1&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;h1&amp;gt;This is my Heading&amp;lt;/h1&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;h2&amp;gt;This is my Sub Heading&amp;lt;/h2&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;p style='color:navy;'&amp;gt; This is blue text&amp;lt;/p&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;p style='font-weight:bold; color:green;'&amp;gt;&amp;lt;u&amp;gt; This is green bold underlined text &amp;lt;/u&amp;gt;&amp;lt;/p&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;p style='color:red'&amp;gt;&amp;lt;I&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; DateTime.Now + "&amp;lt;/I&amp;gt;&amp;lt;/p&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;img img width=217 height=162 id='myImg' src='C:/WINDOWS/Web/Wallpaper/Autumn.jpg'&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;!--[if supportFields]&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;div style='mso-element:header' id=h1&amp;gt;&amp;lt;p class=MsoHeader&amp;gt;&amp;lt;span style='mso-tab-count:4'&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style='mso-field-code: PAGE '&amp;gt;&amp;lt;/span&amp;gt; &amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;div style='mso-element:footer' id=f1&amp;gt; " &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;p class=MsoFooter style='border:none;mso-border-bottom-alt:solid windowtext .75pt;padding:0in;mso-padding-alt:0in 0in 1.0pt 0in'&amp;gt;&amp;lt;o:p&amp;gt; &amp;lt;/o:p&amp;gt;&amp;lt;/p&amp;gt; " &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "Page &amp;lt;span style='mso-field-code: PAGE '&amp;gt;&amp;lt;span style='mso-no-proof:yes'&amp;gt;1&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt; of &amp;lt;span style='mso-field-code: NUMPAGES '&amp;gt;&amp;lt;/span&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; " &amp;lt;span style='mso-tab-count: 12'&amp;gt; &amp;lt;span style='mso-field-code: DATE '&amp;gt;&amp;lt;/span&amp;gt; " &lt;span style="color:#000000;"&gt;+&lt;/span&gt; " &amp;lt;/p&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;![endif]--&amp;gt;" &lt;span style="color:#000000;"&gt;+&lt;/span&gt; "&amp;lt;/div&amp;gt; &amp;lt;/body&amp;gt; &amp;lt;/html&amp;gt; "&lt;span style="color:#000000;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;span style="color:#3333ff;"&gt;&lt;span style="color:#cc0000;"&gt;&lt;span style="color:#009900;"&gt;//Force this content to be downloaded as a Word document&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;span style="color:#3333ff;"&gt;&lt;span style="color:#cc0000;"&gt;&lt;span style="color:#000000;"&gt;Response.AddHeader(&lt;/span&gt;"Content-Type", "application/msword"&lt;span style="color:#000000;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;span style="color:#3333ff;"&gt;&lt;span style="color:#cc0000;"&gt;&lt;span style="color:#000000;"&gt;Response.AddHeader(&lt;/span&gt;"Content-disposition", "attachment; filename=mydoc.doc"&lt;span style="color:#000000;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;span style="color:#3333ff;"&gt;&lt;span style="color:#cc0000;"&gt;&lt;span style="color:#000000;"&gt;Response.Charset =&lt;/span&gt; ""&lt;span style="color:#000000;"&gt;;&lt;/span&gt; &lt;span style="color:#000000;"&gt;Response.Write(strDocBody);&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;&lt;span style="color:#3333ff;"&gt;&lt;span style="color:#cc0000;"&gt;&lt;p&gt;&lt;br /&gt;&lt;span style="color:#000000;"&gt;} &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#3333ff;"&gt;catch&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color:#000000;"&gt;(Exception ex)&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;{ &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;Response.Write(ex.Message);&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color:#000000;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;There is a trick to download your aspx page as word document without coding so much but as the aspx. If you remove the closing body and html tag from the above program and define first three blocks i.e page HTML, page layout definitions and style definitions on the page load event then your aspx page contents will be downloaded as word document. Other contents along with header and footer will defined as the aspx page. You can find it in the next post. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6327673815580642833-8047819099570175853?l=techsynapse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techsynapse.blogspot.com/feeds/8047819099570175853/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6327673815580642833&amp;postID=8047819099570175853' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6327673815580642833/posts/default/8047819099570175853'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6327673815580642833/posts/default/8047819099570175853'/><link rel='alternate' type='text/html' href='http://techsynapse.blogspot.com/2007/03/generating-word-document-dynamically.html' title='Generating word document dynamically with header, footer and page border using ASP.NET (c#)'/><author><name>Arun Kumar</name><uri>http://www.blogger.com/profile/18192345302829265261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6327673815580642833.post-467849455218660240</id><published>2007-03-13T21:26:00.000-07:00</published><updated>2007-03-13T21:57:09.221-07:00</updated><title type='text'>Welcome You All!</title><content type='html'>Dear Friends!&lt;br /&gt;&lt;br /&gt;You are welcome to my blog. I am a Software Analyst and have more than three years of work experience in various technologies (like .NET, JAVA, XML, SQL Server etc.) on web applications, distributed applications, business intelligence applications and data mining applications. In my early days of programming, I took help from many blogs and forums. This blog is for those who are new to technology and looking for some initial help. If you are new in web technology you can ask questions to me. All intermediate and expert programmers are welcome to share their views, suggestions and solutions in this blog.&lt;br /&gt;&lt;br /&gt;Enjoy Programming!&lt;br /&gt;&lt;br /&gt;Arun&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6327673815580642833-467849455218660240?l=techsynapse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techsynapse.blogspot.com/feeds/467849455218660240/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6327673815580642833&amp;postID=467849455218660240' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6327673815580642833/posts/default/467849455218660240'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6327673815580642833/posts/default/467849455218660240'/><link rel='alternate' type='text/html' href='http://techsynapse.blogspot.com/2007/03/welcome-you-all.html' title='Welcome You All!'/><author><name>Arun Kumar</name><uri>http://www.blogger.com/profile/18192345302829265261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
