Shahan Ayyub

Shahan is a Microsoft Certified Professional of .Net. Mostly self taught programmer and a quick learner, who just love to code and always eager to find unique solutions to the common problems. Currently working as an iOS developer.
Shahan Ayyub has written 16 posts for Shahan's Blog

How to load large dataset in DataGridView

Today I came here to discuss a popular industrial issue with a work around, which hopefully, you will find useful. As the title depicts, we commonly have a large data set which needs to be display in DataGridView control and it is expected that the larger the dataset, the greater time it will take to … Continue reading

Best practice to check for DBNull using .Net:

When we retrieve data from database it is very important for to check for NULL values if writing a robust application. Here are following ways on how to accomplish this need: 1) Using System.Convert: There is a direct method available to Check for DBNull. Here is what you have to do: // Assuming that a … Continue reading

IsNullOrEmpty – A user Defined Function in SQL server

This is an equal implementation of C# function String.IsNullOrEmpty in SQL. This function returns 1 if parameter is NULL or empty. Here is the implementation of this function: Implementation: CREATE FUNCTION dbo.IsNULLOrEmpty(@data varchar(max)) RETURNS BIT AS BEGIN if(NULLIF(@data,”)) is NULL return 1 — return 1 when there is a NULL or Empty. return 0 — … Continue reading

Find stored procedure in all databases

Are you looking for a way to find procedure in all databases? In this post you will find a way to search procedure in all databases. There are some other ways to do so but here it will be demonstrated by using dynamic SQL. The attached procedure will prepare a query with respect to all … Continue reading

Format XML using VB.Net

While working with xml it is more meaningful to the user if xml could appear in a hierarchical manner which can increase understandability. For example the below sample is preferable from perspective of readability and understandability: <?xml version=”1.0″?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body> <name>abc</name> <message>Don’t forget me this weekend!</message> </body> </note> while this detracts the … Continue reading

For XML Path in .Net – Ups and Downs

INTRODUCTION: We often write ‘FOR XML PATH’ queries in SQL to get data in XML form. Also we can extract unlimited data from a table via XML queries. The problem I am going to discuss today is how to read FULL contents of “FOR XML Path” sql query. I will describe various techniques to retrieve … Continue reading

This document already has a ‘DocumentElement’ node

This happens when we do not assign name to each row as well as root element. So by default system takes DocumentElement as node name which at later stage throws error on validating node.Here is a snap shot: To resolve this issue, we must have to assign name to the ROOT element. for example this … Continue reading

Error: Cannot serialize the DataTable. DataTable name is not set

This happens when we call WriteXml method of DataTable: This exception is raised when we serializes a DataTable when its TableName Property is not set. So, to stop getting this error you have to ensure that the DataTable have TableName property set. NOTE: This do not worth if you are using XMLDataDocument. But remember, XMLDataDocument … Continue reading

Clone Object Without ICloneable Implementation

Overview: It seems strange when we look at the title that usually experts suggest to clone an object through implementation of IClonable interface. But as I have experience, it is good until we do not have a smart and big application where dozen of relations already exists among the objects and you just need this … Continue reading

Retrieve more than 65535 characters from SQL varchar/nvarchar column

Few days ago, I was stuck in a problem to retrieving data from “varchar(max)” column. The data in the column was more than 30k characters. I realized that we can not retrieve more than 65535 characters from the column using this “regular” statement: Select * from TableA   See how it works in sql: In order … Continue reading