this blog contains information for .net and sql stuffs. You can find various tips and tricks to overcome problem you may be facing in ...

Tuesday, March 29, 2011

Allowing special character in xml with .net in built class

Recently I was finding solution to allowing special character in xml, it can be done by replacing with replaced code. You can check here

But if you are using .net then we have one inbuilt class that replaces all of the special character with replaced code and you don’t need to worry for every special character replacement.

Code sample:

XMLstring = System.Security.SecurityElement.Escape(XMLstring)

Friday, March 25, 2011

Access to the path FileListAbsolute.txt is Denied (Error for TFS Project)

Recently during our development we come to know very strange problem and stuck to find solution for it. We use TFS for source control system for our various projects that adds capability to work parallel. After getting this error we thought it could be problem of user right’s but all people where getting same error during the build.

After going through project checked in files in server we come to know that during check in some one has checked in obj folder and that was causing this issue around the development area. After deleting this from source control and commit these changes, error of access denied was gone.
We also found same solution in after searching on internet.

Monday, March 21, 2011

Allow special character in XML

XML is very useful in any of the programming language. You have many controls of your data representation. One of the features of platform independent makes vital use of it.

In actual data we have different characters which are not supported in XML if we directly write in it. Here are some lists which can be used to replace actual character in XML.

Less than < can be replaced with &lt

Greater than > can be replaced with &gt

Ampersand & can be replaced with &amp

Quotation "can be replaced with &quot

Apostrophe ' can be replaced with &apos

At the end of replaced character we should keep one ;

Hope this list is useful when we want to use special character in XML.

Wednesday, March 2, 2011

Get next identity value in my table For SQL Server

It may require some time to know what will be our identity value before we actually insert record in our table. Usually we tend to find our max id value by selecting max id from records. But it may be possible you deleted records and now you want to know next identity value. SQL server has given a very nice function for it.

SELECT IDENT_CURRENT(‘mytable’)

In above line, mytable is table name, in which we want to find next identity value. Very impressive function!!

Thursday, February 3, 2011

Paging stored procedure for the SQL server 2000

Before a while ago, I have posted query for the true paging but it does not work in SQL server as ROWNUM is not available in it.

Here, is the sample stored procedure for SQL Server 2000

CREATE PROCEDURE [dbo].[State_Search]

@SearchText nvarchar(50) = null

,@PageNo int

,@PageSize int

,@TotalRecords int OUTPUT

AS

BEGIN

SET NOCOUNT ON;

DECLARE @StartFrom int

SET @StartFrom = @PageSize * (@PageNo - 1);

CREATE TABLE #tmpState (

RowNo int IDENTITY(1,1) PRIMARY KEY,

RowId int NOT NULL

);

INSERT INTO #tmpState(RowId)

SELECT CHECKSUM([State].StateGuid) FROM [State]

WHERE (@SearchText IS NULL OR StateCode LIKE @SearchText OR

StateName LIKE @SearchText OR StateDesc LIKE @SearchText)

SET @TotalRecords = (SELECT COUNT(*) FROM #tmpState);

SELECT

[State].*

FROM #tmpState

INNER JOIN [State] ON CHECKSUM([State].StateGuid) = #tmpState.RowId

WHERE #tmpState.RowNo > @StartFrom AND #tmpState.RowNo <= (@StartFrom + @PageSize)

ORDER BY #tmpState.RowNo;

SELECT @TotalRecords AS TotalRecords;

DROP TABLE #tmpState;

END

Wednesday, January 5, 2011

OCR In .net with MS-Office 2007 component (MODI)

I have been just passed through requirement to implement OCR in one of my .net application. There are very less option available in .net to implement it. I thought to share with you what I have learned at that time.

In .net OCR can be done with Ms-Office component, it’s the Microsoft Office Document Imagining Library. It is required to have ms-office on your pc before you develop or run this application. This component is available in both ms-office 2003 and 2007.

Initially when we install our office, it does not install image library in our pc, we need to install it explicitly. When you start to add/remove features in your office you need to check following things should be included.







Once you have installed it, you can start to develop your application.

You can take any project type either windows or console. Now you need to add reference of Document Imaging Library to your project, that will be available in com tab of add reference dialog box. Please note down that this will be only shown if you have installed it correctly. If you don’t able to see it though you have installed, try to restart your system and then check it again.




Once you have added that com reference you can work with images and can read text from it.


Tuesday, September 7, 2010

Difference between build and rebuild

In vs we find two options build and rebuild for our solution and very rarely we give attention what do we require.

There is very much difference between both of them, if you have noticed it, build takes less time compared to rebuild.

When we build application it complies files which has been changed it does not compile all files in project, while in case of rebuild it compiles all files weather it has been changed or not. Mainly rebuild should be done when so many files are changed and also it might possible some files are changed outside of IDE.

Hope this information will help to speed up your application when you choose rebuild instead of build.