Announcement: SocialShare Starter Kit (v1.0) is Released

SocialShare Starterkit v1.0 Relaesed. SocialShare Starter Kit is a kick start application that illustrate a wide range of features that needed to build a social site. And includes features like Status sharing,Blogs,Forums & more. Any one need a lightweight quick solution for his social portal,SocialShare Starter Kit is the savior.SocialShare Starter Kit uses T-4 templates to build logical layers (i.e. DAL/BLL) . The logical layers implemented here are based on Entity Framework 4.0. Its also a good example to learn T4 template and  how to utilize them work with asp.net data bound controls with minimum effort. I am continuously adding and fine tuning the existing feature list and performance. Checkout the app from codeplex SocialShare Starter Kit Home also documentation is available SocialShare Starter Kit documentation

How to solve Log4Net Config Error

Background

While using log4net for logging and using a separate configuration file I encountered a strange error that log4net cant locate the configuration file, even though file and configurations are already there. This problem drive me nuts and finally i found few solutions to fix the problem.

log4net error

Problem Scope

My particular applications is designed as such

log4net-concept

So as shown in diagram, several type of app type will hookup with Log4Net wrapper to get logging facility and all logging related logic’s are implemented on Log4Net wrapper. As the problem states every time a client app is trying to invoke log4net wrapper it gets xml configuration error “Check your .config file for the <log4net> and <configSections>….”

Solution

There is few problem and few solution, Solution can very on context.

On the client project , select Log4Net config file and set this file to Build Action of Content with Copy to Output Directory of Copy Always.

Another alternative is look for  XmlConfigurator.Configure();. This line is responsible for initiating the log4net. This configuration should exist a single place where logging actually happen, not client app’s.

One of these 2 or both tricks should help to solve this problem.

tea country a weekend getaway

After long work weeks me and my wife decided to take some day off. We are trying to make it a habit of after each 3/4 exhausting work week we go out for a short vacation, not long , max 3 days, and believe me it recharge you like no other thing. Usually our favorite place is beach but this time we decided to take a different route , its rainy season in bangladesh and at this time no other place could be as beautiful as sylhet our one and only tea county. I went to srimangal (a upazila  under sylhet division) several times, but for my wife its a new territory, so I made up my mind I will take her to sylhet first and later of the year may be srimangal.

This post is more or like informative post for new bees, let me try to put together as much as info as possible to aid new visitors.

How to reach sylhet

there is good communication from major citys to sylhet. You will get trains, buses (AC/ No AC). If you are traveling from Dhaka train leaves from Dhaka to sylhet twice a day. And there is several bus services from dhaka to sylhet all day long. I recommend to take Green line bus  , its AC bus, comfortable, good service and fair is also reasonable 900tk, you can take non a/c buses like shamoli/tr paribahan which is non a/c fair is 400tk. You will reach to Humayun Rashid Circle  (HRC) from which you can take CNG (local cabs) or rikshaw to reach your hotel.

Where to stay

Sylhet city is full of hotels ranging from 400tk 10k per night depending on your budget. Good thing is most of the hotles are inside city and easily reachable. I stayed at Hotle Supreme, good service, decent food,  reasonably comfortable rooms.  you can get a a lots of hotel name by googling.

Hotle Supreme, Mirabazar — 01711197012 (cell phone)

Hotel Valley Garden, Bishwa Rd,  —- 0821-727602 (cell phone)

Hotel Garden Inn. Garden Tower, Shahjalal Bridge Link Road — 0 1711271185, 0 821 727284 (cell phone)

Where to eat

For foreigners it could be bit tough to try local restaurants as they serve mostly native and popular local dishes, so I recommend to stick to restaurants within the hotel, for local travelers there is lots of options but i feel it hard to find a decent restaurants  with good quality food. me and my wife tried a few, even some of them get very high recommendation from diff travel sites, but few of them could coupe with reputations, we find the Exotica restaurant within hotel supreme  decent and more or less good quality local food but dont event try the thai/Chinese dishes :). You can try woondal/vojon bari for change of taste

How to roam around

You have to rent a vehicle to roam out side of town , but for roaming inside town CNG/rickshaw is more then fine. CNG and rickshaw fair is reasonable. You can get rented vehicle ambarkhana or madina market area inside town. You can ask your hotels also to arrange a ride for you, but in that case price will be higher. I managed to get a very good driver and guide. He willingly guided the whole tour and take us to places that we don’t know exist inside the city, you can pick him up if he is free, Mr Alamgir– 01712068709 (cell phone)

Places to see

All the photos are taken by my Canon 60D myself, Though I am listing out few places but the on they way to reach these places is as much beautiful as they are.

IMG_1831

Malinichora Tea Estate

 

Malini Chora Tea estate is one of teh most visited tea estate in sylhet, located near to sylhet city, easily reachable via CNG (local name of  CNG driventaxi) or rikshaw

 

 

 

 

 

 

Madhobkunda waterfall

Madhobkunda waterfall

 

Madhobkunda is one of the larges waterfalls in bangladesh and one of the most visited tourist spot in sylhet. On the way you can see the tea garden, the hills and the zigzag road through the hills. For me best time to visit there is rainy season from june to august, at that time waterfall came with her own strength and beauty……. breathtaking.

 

 

 

 

jaintapur hill resort

jaintapur hill resort

 

The resort is is nearly 1h drive from sylhet city and a good place for relaxation, main attraction is you can see 2 waterfalls from maghalaya (india) in distant , two waterfalls, which are ten times bigger than the Madhabkunda falls, will blow your mind! But alas those are in india, so what we can peek those from this resort :)

 

 

 

 

 

 

Lalakhal

Lalakhal

 

This is a wide canal known as Lala Khal & near zero point with india . It is the source of Sylhet Sand . The attraction of this canal is the water, which differs in colour at different point. In the same canal, you will find blue, green, clear water. No one will believe this without having watch. You cat take a boat ride here , 30min ride will cost 500tk.

 

 

 

 

Jaflong

Jaflong

 

situated at the border between Bangladesh and the Indian state of Meghalaya, overshadowed by subtropical mountains and rainforests. Jaflong is famous for its stone collections and is home of the Khasi tribe. On they way to jaflong landscape is breathless, you will often like to get out of ride to actually enjoy the view……………………………….. ohh wait thats what I did

 

 

 

 

When to plan the trip

In general people come to sylhet at pick season during winter, from october to February, when weather is not much hotter. But I prefer rainy season. During rainy season tea gardens, waterfalls , rivers flourish with beauty, I recommend not no miss that for anything. There is hand full of tour operator available who will arrange the trip for you any time of the season, but my opinion is do some homework about the place and arrange the trip yourself, that’s is much more exciting. At least that’s what I always do. Its a friendly place with friendly people,  give it a try I am sure you will love it.

Day Out At Bangabandhu Sheikh Mujib Safari Park

Charm City

Very recently for business purpose I had this opportunity to visit maryland @USA,  to be specific balitimore city.  Like always my business or family visit always became visit with pleasure :) and my explorer string hidden inside start poking. To be honest its very hard to find time in business trip but still I haven’t missed any opportunity to explore for sure.

I kept hearing and seeing people all around the city named balimore city as charm city. I was wondering why people call baltimore city charm city,  So I took this noble responsibility on my shoulder and start exploring.

First thing I always do is gather interesting info about places I visit, it keeps me going till end and bond with the place i visit, people I talk with. I know sounds bit unusual but…. hey everyone has own way of keep the dice rolling…. no! :)

Baltimore is the second largest seaport in the Mid-Atlantic United States.  Almost a quarter of the jobs in the region are science, technology, engineering and math positions (Of course that’s why I am here).

027 030Wherever you go to city somehow you will see term “charm” used, Its been said during 1975 an attempt to prompt the city’s  image , leaders of the city’s largest advertising agencies come up with this name which is stuck forever and in times became worthy. That city is beautiful,  people are friendly and food is awesome. Lost of activities and place to see for tourists. Like other USA city’s baltiomore people’s are crazy about their home team “Baltimore raven’s”

TSQL function to replace HTML tags with delimiter

Introduction

Its often needed to remove all html tags for a column(s) from a database table. One way to do is regular expression pattern matching or using a custom function that will hunt down html tags and remove them. In this small post I will demonstrate this second method.

T-Sql Function

Here is a very simple function that replace/remove html tag’s and returns clean texts without using any patterns. Additionally you can pass a delimiter that will replace the html tag’s in-case you do not want to mix everything in one big chunk of text.

CREATE FUNCTION [dbo].[CleanHTMLTags] (@HTMLText VARCHAR(MAX),@ReplaceChar char(1))
RETURNS VARCHAR(MAX)
AS
BEGIN
DECLARE @Start INT
DECLARE @End INT
DECLARE @Length INT

SET @Start = CHARINDEX(‘<‘,@HTMLText) SET @End = CHARINDEX(‘>’,@HTMLText,CHARINDEX(‘<‘,@HTMLText)) SET @Length = (@End – @Start) + 1 WHILE @Start > 0 AND @End > 0 AND @Length > 0
BEGIN
IF (UPPER(SUBSTRING(@HTMLText, @Start, 4)) <> ‘
‘) AND (UPPER(SUBSTRING(@HTMLText, @Start, 5)) <> ”)
begin
SET @HTMLText = RTRIM(LTRIM(STUFF(@HTMLText,@Start,@Length,@ReplaceChar)));
end
ELSE
SET @Length = 0;

SET @Start = CHARINDEX(‘<‘,@HTMLText, @End-@Length) SET @End = CHARINDEX(‘>’,@HTMLText,CHARINDEX(‘<‘,@HTMLText, @Start))

SET @Length = (@End – @Start) + 1
END

RETURN isnull(RTRIM(LTRIM(@HTMLText)) ,”)
END

And thats it. Say you have a table named “PRODUCTS” and that contains a column “ProductDetails” that contains html tags, in our scenario we have to remove all html tags and replace them by comma(,). Utilizing above function we can make the call like this

SELECT [dbo].[CleanHTMLTags](ProductDetails,’,’) FROM PRODUCTS

Resultant data should be a big text respect to each records in “PRODUCTS” table with html tags removed.

Solution To The MSSQL Server “Suspect”

Background

When you see the your database in Suspect mode that a code red situation. Its not something that you face everyday. It can happen, however, most often due to faulty hardware or operational mistakes (like deleting a transaction log file). This post will show how to recover from suspect mode, but still go through SQL-server error logs and find out the root cause of the error.

Reason

At start-up, SQL Server attempts to obtain an exclusive lock on the device file. If the device is being used by another process  or if the file is missing, sql server start displaying error.

In these cases, there is usually nothing wrong with the devices and database. For the database to recover correctly, the device must be made available, and the database status must be reset.

Possible reason for changed to suspect mode in sql server can be

  • The system cannot find the file specified.) during the creation/opening of physical device
  • Failed to open device where data or log file resides
  • SQL server went down/restarted in the middle of a transaction causes transactions log to be corrupted
  • SQL server can not access data or log file while coming online , because of you beloved antivirus

Solution

To resolve this issue run the commands listed below,

EXEC sp_resetstatus ‘DATABASE_NAME';
ALTER DATABASE DATABASE_NAME SET EMERGENCY
DBCC checkdb(‘DATABASE_NAME’)
ALTER DATABASE DATABASE_NAME SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB (‘DATABASE_NAME’, REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE DATABASE_NAME SET MULTI_USER

What the above command do is perform a series of step to check the logical & physical consistency of the database and tries to repair. Very first step is to turns off the suspect flag on a database, you can achieve his by using sytem stored procedure sp_resetstatus. Using this procedure change the suspect flag to emergency. Once the database is set to EMERGENCY mode it becomes a READ_ONLY copy and only members of sysadmin fixed server roles have privileges to access it. Then perform a consistency check by executing DBCC command on the master database.  Next step is to rollback any transactions if any are present in the database and bring the database  into Single User mode. Run the repair and finally bring database to Multi User mode.

Remember sp_resetstatus can be executed only by the system administrator. Always shut down SQL Server immediately after executing this procedure.

If the database is still marked as suspect after performing these steps, there may be other problems preventing the database from recovering. At this point, only option left is either restore from a good backup or set the database to emergency mode and use the bulk copy program copy the data out.

TSQL Recursive Split Function

Background

In my last post I showed how to split a string in TSQL. Problem with that splitting is it can split a string if resultant split count is <=2, i.e. it can split only string like “a,b” or “first,last” or “java,c”. But while doing the parsing of  string of whom resultant split count is >2, it wont work. We need more effort to do so.

Solution

I am gonna show how to split a string of any number of delimiter and we will recursive function to achieve that. Idea is very simple,  Create a function that will take the input string and get the first index of delimiter and return the string up to first index and insert that first half into a table. Next is find the rest of the string other then first half and call the same function with it. This loop continues until we find there is no delimiter left in string to do further recursive call, so we return the original caller function and all the way to parent function who initiate the recursive call.

Implementation of the above idea is the function illustrated below,

CREATE FUNCTION [GetName] (@StrVal nvarchar(MAX),@delimeter nvarchar(1))
RETURNS @OldNames TABLE (Name varchar(MAX))
AS
BEGIN
DECLARE @SplitVal nvarchar(MAX);
DECLARE @RestOfTheStrVal nvarchar(MAX);
SET @SplitVal=LTRIM(SUBSTRING(@StrVal, 0,CHARINDEX(@delimeter,@StrVal)));
SET @RestOfTheStrVal=LTRIM(SUBSTRING(@StrVal, CHARINDEX(@delimeter,@StrVal)+1,len(@StrVal)));

IF CHARINDEX(@delimeter,@RestOfTheStrVal)<=0
BEGIN
IF @SplitVal IS NOT NULL
INSERT INTO @OldNames(Name) SELECT @SplitVal ;
IF @SplitVal IS NOT NULL
INSERT INTO @OldNames(Name) select @RestOfTheStrVal;
return;
END
INSERT INTO @OldNames(Name)
SELECT @SplitVal
UNION
SELECT Name FROM dbo.GetName(@RestOfTheStrVal,@delimeter)
RETURN
END

And this time  let me remind you this solution is applicable  if you have a string with a single delimiter (means you can use only one delimiter). Though its returns resultant strings as a tabular format, its quite handy for situation like I explained above.

TSQL split a string by delimiter

Background

Say we have a registration table which store successful registration info. At that table we have a column “Name” which stores value as combination of first name & last name delimited by ‘ ‘ [space]. Later at some point we need to extract the first name or last name from that column, what to do?

Solution

Solution is a simple technique that will take given input string (or column in my scenario) and split against the given delimiter. Technique is get the first index of delimiter and return the string up to first index and return the first half. For second half start from first index of delimiter and take till end of input string and you will get second half. Simple isnt it !!

objects-substring

– Split and get the first half, delimiter is ‘ ‘ [space]

LTRIM(SUBSTRING([COLUMN_NAME], CHARINDEX( ‘ ‘,[COLUMN_NAME])+1,len([COLUMN_NAME])))

– Split and get the second half, delimiter is ‘ ‘ [space]

LTRIM(SUBSTRING([COLUMN_NAME], 0,CHARINDEX(‘ ‘,[COLUMN_NAME])+1))

And let me remind you this solution is only applicable if you have a string with a single delimiter and resultant split count is <=2. Though is small and wont work for more then one delimiter but its quite handy for situation like I explained above.

Living in mysterious world

Do you think history is boring? think again!! Here is the list of my favorite documentary that changed my thoughts on histories,. Enjoy

History's Mysteries

Lost City Of Atlantis

Ancient X Files

The Holy Grail

The Pyramid Code

How to solve SSIS error code 0xC020801C/0xC004700C/0xC0047017

Background

SSIS is the one of the best ETL tool available in market and it can load large amount of data from any heterogeneous data source whether structured, unstructured,application, cloud or real-time data. This post discuss the solution of a common problem that usually arise while importing data from excel data source.

Problem

For beginners while doing the extract, face some weird issues, which seems very fuzzy to solve at first. Such a problem is while doing extract from excel data source, after running the application shows error,

at Package, Connection manager “Excel Connection Manager”: SSIS Error Code DTS_E_OLEDB_EXCEL_NOT_SUPPORTED: The Excel Connection Manager is not supported in the 64-bit version of SSIS, as no OLE DB provider is available.Error: 0xC020801C at Data Flow Task — Excel File, Excel Source [1]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.  The AcquireConnection method call to the connection manager “Excel Connection Manager” failed with error code 0xC00F9304.  There may be error messages posted before this with more information on why the AcquireConnection method call failed.Error: 0xC0047017 at Data Flow Task — Excel File, SSIS.Pipeline: component “Excel Source” (1) failed validation and returned error code 0xC020801C.Error: 0xC004700C at Data Flow Task — Excel File, SSIS.Pipeline: One or more component failed validation.

And the extraction failed.

Reason for this run-time error is excel do not have 64-bit driver which is selected by default in SSIS running on 64bit OS. So solution is also hidden behind the reason, change the driver from default and you are good to go. Steps to solve is issue is,

Step 1: Navigate to Project-> [PROJECT_NAME] Properties.

Capture

Step 2: Navigate to “Debugging” option from left panel and from Right panel change Run64BitRuntime value to false.

Capture-2
that’s it !! Keep extracting !!

Follow

Get every new post delivered to your Inbox.

Join 249 other followers