Using Rowcount and Top keyword for controlling number of records returned

Hi,

Many a times in a query we need to limit down the number of records returned in the query. This can be done in two ways using the TOP keyword or the row count keyword.

Select top 10 from Table

This will return the top 10 records from the query. We can also make this dynamic by making the Value in Top keyword to come from a variable.

DECLARE @top INT
SET @top = 10
SELECT TOP(@top) * FROM Table

Continued...

Programmatically Embedding another file to the word document

Hi

Many a times we want to embed some document in the word file, with the help of Insert-> File-> Select File menu item. This will copy the content of the file to the word document. This can also be done programmatically. 

String LocationOfFileToMerge = "C:\\Myfile.doc";

range.InsertFile(LocationOfFileToMerge,ref oMissing, ref oFalse, ref oFalse, ref oFalse);

We can also embed the document in the word file instead of copying the text of the document. In this case you can embed any kind of document.


Object NameForLabel = "File Name";

Continued...

Word Automation and Basic text formatting option

Hi,

when you start working with word programmatically, many a times you will have to add some text in the word document with formatting. Word automation gives you easy way top format the text that you are writing in the Word document programmatically.

To make the same impact as would an enter button in the word document we can use the following code.

oWord.Selection.TypeParagraph();

Basically this will enter a new paragraph in the word document. But you are in a bullet mode than this will take you to next line and also add the next bullet in the sequence.

Some of the common word formatting functionality can easily be performed with the help of word automation.

Continued...

Word automation and find and replace in Word document

Hi,

In My last two posts I talked about

·         How to open and close a word document programmatically.

Continued...

Saving word document in different format using Word Automation

Hi,

In my last post I talked about how to open and close a word document programmatically. In this post I will talk about how we can save the word document.

While using a word document there can be three kind of save functionality that can be required.

1.       When we open an existing word document and make some changes to the word document and save the word document.

Continued...

Microsoft word 2007 automation with C Sharp

Hi,

Some time in our project we need to work with word (winword) document programmatically. Word provides a good way to automate nearly all the functionality that can be used through interface.  The process of programmatically working with word document is commonly termed as word Automation.

I will be using a series of blogs to discuss some of the functionality that can be achieved through word automation. In this Blog I will discuss how we can start programmatically open a new or and existing word document and close it.

To work with word 2007 automation we need to have the word 2007 installed in the machine where the application will run. When we install the word 2007, it also installs with it the com component required to automate word 2007.

Continued...

Large Blob Data problem in Oracle stored procedure

Hi,

Few days back I was working with Oracle database and one of my stored procedures which was inserting a blob data to the database.  But I started getting a strange when the data in the blob data type got large. For large blob data I was getting the following error.

ORA-01460: unimplemented or unreasonable conversion requested.

The system would work consistently for small files but for large files I was getting this error.  After Doing a bit of Google I found that this is a drawback of using stored procedure in Oracle database.  If you try to pass over 32 Kb (or greater than 32512 char of string) then oracle will give this error in case of Blob data type.

Continued...

Using Lazy Loading Design pattern to load data when required

Hi,

Some time when you are working with large objects where some of the data (properties in the object) is not required frequently, the use of Lazy loading is the best.

 Let’s say you have an Object which contains many properties along with a property for exposing long XML string. The long XML string is only required to be shown only a few times when you are also showing the details of the object. At this point when we are loading a list of this object to display (where by XML string will not be displayed) its not a good practice to also load the XML string in the object. Since this would take lots of extra Network bandwidth and memory space.

Continued...

Visual Studio 2008 and dot net frame work 3.5 service Pack 1 beta out

Hi,

Yet another big news for dot net frame work 3.5 and Visual studio 2008. Microsoft has released the beta 1 of the Dot net frame work 3.5 and visual studio 2008. Some of the major issues taken care of in the service pack are

·         Various fixes to issues found by Microsoft and our Customers

Continued...

Get current GMT Time in Oracle and MSSQL

Hi,

Many a time with all the data we want to store the current date time for reference purpose.  If your application is going to work with more than one country than its best to store the date time in UTC (GMT) format.  With difference database the way to get the current UTC date time is different. Here is a list of way to do the same for different database.

Oracle 9i and above

select new_time(sysdate,'EST','GMT') into Result  from dual;

Don’t forget to change EST with the current time zone of the database.

MS SQL 200 and above

GETUTCDATE()

Continued...

Asp.Net List Box control and flickering issue

Hi,

Last few days I was working on a page which had lots of list box in it which had multi select option. My master page also had a Menu control for the navigation purpose.  One major problem I was facing was with the flickering of the List box as soon as take my mouse over the menu.

Continued...

Handling Dropdown list inside Gridview with Autopostback

Hi,

Many a times there are circumstances where by we need to use dropdown list inside a Gridview and also handle the index changed event of the dropdown list. The easy example of this kind of requirement would be when we nee to fill another dropdown list in the same row from the value selected in the first dropdown list.

We all know that the dropdown list does not support command name property so you cannot handle the event in the row command event.

Continued...

Sorting and Paging Gridview without datasource control

Hi

Many a times while working with Gridview we want to work with the paging and sorting functionality without using any datasource control. Gridview is flexible enough to perform these tasks without the use of any datasource control and only a few lines of code.  

For paging a Gridview manually we have to handle the Gridview’s PageIndexChanged Event.  In the event we need to change the PageIndex of Gridview to the page that user has clicked and again bind the Gridview.

Continued...

Open format design awards goes to Microsoft Open Office XML

Hi

Microsoft has won international standards designation for its open-document format, according to voting results obtained Tuesday, apparently ending a divisive yearlong battle with software rivals before a global standards-setting organization.

Vikram


IIS7 gets many new admin tools

Hi

Its been a few days that I have not been able to post blogs. I have been very busy these while. But yesterday I found this blog which talks about lot of cool new admin modules for IIS7.  The blog also explains how to use the modules. Do check it.

Vikram


Creating a list of the data cached at a point in the asp.net Application cache

Hi,

 

We all know about the use of caching in our application. With good use of cache we can increase the performance of the application considerably since application does not have to process the stuff again and again. But if we use too much of caching in the application, it can be problem. After all the data in the cache has to be stored in the memory and most of the application have limited memory. And more so in case of shared hosting.

 

Continued...

Reading, writing and deleting cookies in client side using JavaScript

Hi,

 

I have discussed about cookies in my previous posts. But in all those posts I talked about working with cookies in server side.

You can read these posts here

 

Continued...

SilverLight 2.0 Beta 1, Asp.net MVC preview and IE8 Beta1 out to public

Hi,

 

Seems like Microsoft has decided to go for many releases on a day on the first day of MIX. Yes today Microsoft not only announced the release of IE8 Beta1 but also the preview of the Asp.Net MVC and Silverlight 2.0 Beta 1. This is way too much to work on at the same time. But who is complaining. :-)

 

Continued...

IE8 beta 1 is out for grab

Hi,

 

The beat 1 of the most dominated web browser’s next version is out for grab and it comes with many features too. The IE8 Readiness Toolkit which will give a detailed description of the features. You can download the same here.

 

Some of the new features are

 

Continued...

Going mouse less using keyboard shortcut in Asp.Net

Hi,

 

Many a times when working with the Web Application you would like to give the user the comfort of getting the job done without using the mouse. It can be of great use to the user if they can perform many tasks using the keyboard in a web application. If you have used Gmail you would know how easy it can be to select mails using some key.  This feature can be implemented in Asp.net also very easily.

 

Continued...

IIS Website relaunched by Microsoft for the launch of Windows server 2008

Hi,

With the launch of Windows Server 2008 today Microsoft also relaunched the website for IIS.  Do check the newly relaunched website of IIS here

 

Vikram


SharePoint Permission problem when programming Object model with trust level WSS_Minimal

Hi,

 

Last few days I was playing with SharePoint server 2007 and programming with it. All I was trying to do was add a list item in a simple list created in the SharePoint through a web part. The code to do the job was simple enough.

Continued...

Content Page referencing content in Master Page

Hi,

 

Many a times while using a master page we want to refer content, Controls and properties in Master Page while working in Content page. We come across requirement where by we can change or access the values of controls residing in Master page when we are coding in the content page itself.

 

We can write code in the content pages to access properties, methods and controls in the master page, but there are some limits to it. We can only work with those properties and methods which are declared public. For controls we can refer any control on the master page independent of referencing public member.

Continued...

Redirect and refresh a page using the Meta tag

Hi

 

Many a times we have a requirement where by we want to make a pager refresh by itself at a certain interval. We may also want to redirect the page to another page after a certain amount of time. I know we can do this with the help of Asp.Net Ajax Extension’s Timer control. But that can only be used when you are using Ajax in your page and more importantly should be used when you have requirement to update some small section of the page. For this requirement we can simply use a Meta tag in the Page header.

 

Continued...

February CTP for SQL server 2008 has been launched

Hi,

 

As all of us know that SQL server 2008 Launch has been delayed to 2nd half of the year, but the Feb CTP has been released. The CTP is feature complete. The CTP include better functionality for Data compression, Policy based management enhancement. Integrated full text search engine and many more functionality.

 

Continued...

Obsolete API list for Dot Net framework 2.0

Hi,

Microsoft has come out with a list of APIs which have become obsolete in the .Net Framework 2.0. The same can be accessed from: .NET Framework V2.0 Obsolete API List. The list also contains alternate APIs that can be used for most of the obsolete APIs. In case there is no alternative suggested then this means that there is no replacement for the API.

You can also check the list grouped upon Asembly Here and Grouped by Namespace here.

Vikram


Using ObjectDataSource and passing Object as a parameter

Hi,

 

ObjectDataSource was a great addition to Asp.Net 2.0. But when working with asp.net 2.0’s ObjectDataSource had one limitation when working in Visual Studio designer. When working with ObjectDataSource we cannot pass object as a parameter. We always need to pass string, integer etc as the parameter.

 

But many a times we want to pass some object as parameter instead of passing all the values as string. Passing all the values can also be difficult when working with large number of columns.

 

Continued...

Asp.net Timer control tweaking on the client side

Hi,

Few days back I saw this question in the forums and from then I was looking for an answer for it. The Timer control in the asp.net Ajax is pretty useful when we want to do some activity on the client side at a certain interval of time. The control also gives us good control on tweaking it on the server side. But Sometime the requirement is such that we want to change the value of timer interval, or stop the timer on the client side itself.

A few days back I learned that the timer control can easily be tweaked in the client side also. Let’s assume we are using a timer control with ID Timer1.

 

var Timer1 = $find(‘<%= Timer1.ClientID %>’);

 

Continued...

C Sharp and yield keyword

Hi,

 

One of the cool and yet most unknown feature of the C# is the yield keyword. The yield keyword is used in an iterator block to provide a value to the enumerator object or to signal the end of the iteration. When used the expression is evaluated and returned as a value to the enumerator object. Note the expression has to be implicitebly convertible to yield type of the iterator. Here is an example

 

Continued...

Concurrent request and how session behave

Hi

 

We all have worked with Asp.Net session objects in some point of time. An interesting question came in between the discussion with my colleagues on concurrent request and session state.  Here is what I have to share with all on session and concurrent users.

Continued...
 
Copyright © 2006 - 2008 Vikram Lakhotia