Sunday, October 27, 2013

Microsoft : Junk Email Filter for Outlook

I found a plug from Microsoft outlook which reduces these emails. This is a free plug-in available for users of Microsoft Outlook 2007, 2010 and 2013 which you can download from here.

After installing it, and restarting Outlook, you will be able to report Junk by right-clicking the email and selecting Junk à Report Junk

The software will do the rest for you.

Hope this helps!!

Thursday, October 24, 2013

How to hide Validation Summary from JavaScript in .NET?

Here is how you can hide validation summary using the below JavaScript.  Call this in your aspx page. This should do trick for you.

function HideValidationSummary(){

if (typeof(Page_ValidationSummaries)!= "undefined"){ //hide the validation summaries
for (sums = 0; sums < Page_ValidationSummaries.length; sums++) {
summary = Page_ValidationSummaries[sums];
summary.style.display = "none";
}
}

}

It works in IE and Mozilla. Hope this helps

 

Tuesday, October 08, 2013

iPad microphone not working with Skype

Recently I ran into this issue as all of a sudden my Skype microphone stopped working. I tried to re install it and that doesn’t work for me. Later I realized that I have recently updated my iPad to iOS 7 which could cause some privacy settings.

So I looked into settings and found that my micro phone setting for Skype were blocked. Here is how we can un block it again

Go to Settings > Privacy > Microphone > Skype

Hope this helps for users like me..

Friday, September 27, 2013

SQL: Data Types

Data Type Syntax Explanation (if applicable)
integer integer
smallint smallint
numeric numeric(p,s) Where p is a precision value; s is a scale value. For example, numeric(6,2) is a number that has 4 digits before the decimal and 2 digits after the decimal.
decimal decimal(p,s) Where p is a precision value; s is a scale value.
real real Single-precision floating point number
double precision double precision Double-precision floating point number
float float(p) Where p is a precision value.
character char(x) Where x is the number of characters to store. This data type is space padded to fill the number of characters specified.
character varying varchar2(x) Where x is the number of characters to store. This data type does NOT space pad.
bit bit(x) Where x is the number of bits to store.
bit varying bit varying(x) Where x is the number of bits to store. The length can vary up to x.
date date Stores year, month, and day values.
time time Stores the hour, minute, and second values.
timestamp timestamp Stores year, month, day, hour, minute, and second values.
time with time zone time with time zone Exactly the same as time, but also stores an offset from UTC of the time specified.
timestamp with time zone timestamp with time zone Exactly the same as timestamp, but also stores an offset from UTC of the time specified.
year-month interval Contains a year value, a month value, or both.
day-time interval Contains a day value, an hour value, a minute value, and/or a second value.




Thursday, September 19, 2013

What’s new in iOS 7.0

Apart from bug fixes and beautiful new design here are few new features that are part of iOS 7 release.

  • New design
    • Redesigned interface updates the entire system and every built-in app
    • Subtle motion and animation; layers and translucency provide depth
    • Elegant new color palette and refined typography 
    • Updated system sounds and ringtones
  • Control Center
    • Quick access to commonly used controls and apps with a swipe up from the bottom of the screen
    • Turn on & off Airplane Mode, Wi-Fi, Bluetooth, Do Not Disturb; adjust screen brightness; access media controls; turn on AirPlay and AirDrop
    • Quickly access flashlight, timer, calculator, camera and music controls
  • Notification Center improvements
    • New Today view gives you an overview of your day, including weather, calendar, and stocks 
    • Notifications dismissed on one device dismisses across all your devices
  • Multitasking improvements
    • Preview screens of open apps when you switch between them
    • Permits any app to keep content up to date in the background
  • Camera improvements
    • Swipe through different camera modes – video, still photo, square aspect, and panorama
    • Real-time photo filters with iPhone 4S or later, and iPod touch (5th generation)
  • Photos improvements
    • Automatically organizes your photos and videos based on time and location into Moments
    • iCloud Photo Sharing supports multiple contributors and videos, plus a new Activity view
    • Add photo filter effects
    • Flickr and Vimeo support
  • AirDrop
    • Quickly and easily share content with people nearby
    • Securely encrypted transfers with no network or setup required
    • Supported on iPhone 5, iPad (4th generation), iPad mini, and iPod touch (5th generation) and requires an iCloud account
  • Safari improvements
    • New iPhone tab view that lets you easily switch between open web pages 
    • Unified smart search field for both search terms and web addresses
    • Shared Links shows web pages shared by people you follow on Twitter
  • iTunes Radio
    • Streaming radio service
    • Pick from over 250 featured and genre-focused stations
    • Start your own station from your favorite artist or song
  • Siri improvements
    • New, more natural sounding male and female voices for US English, French and German
    • Integrated Wikipedia, Twitter search, and Bing web search results
    • Change settings including Wi-Fi, Bluetooth, and brightness
    • Supported on iPhone 4S, iPhone 5, iPad with Retina display, iPad mini, and iPod touch (5th generation)
  • App Store improvements
    • See apps relevant to your current location with Popular Near Me
    • Discover age-appropriate apps in the Kids category
    • Keep your apps up to date automatically
  • Find My iPhone Activation Lock
    • Turning off Find My iPhone, erasing your device, reactivation, and signing out of iCloud requires your Apple ID password 
    • A custom message can be displayed on your device even after a remote erase
  • iTunes Store improvements
    • Preview and buy songs you've heard on iTunes Radio while inside the iTunes Store
    • Add to, and shop from, your iTunes Wish List
    • Scan code with camera to redeem iTunes Gift Cards 
  • Music improvements
    • Play music purchases from iCloud 
    • Rotate your iPhone or iPod touch to browse your music with the Album Wall
  • Videos improvements
    • Play movie and TV show purchases from iCloud 
    • View similar movies and TV shows from Related
  • Maps improvements
    • Turn-by-turn walking directions
    • Automatic night mode 
    • Bookmarks shared across devices via iCloud
  • Mail improvements
    • New Smart Mailboxes, including Unread, Attachments, All Drafts and To or CC
    • Improved search
    • View PDF annotations
  • FaceTime audio calling
  • Block unwanted Phone, Messages and FaceTime callers
  • Support for sending long MMS messages
  • Pull down on any Home Screen to reveal Spotlight search
  • Scan to acquire Passbook passes
  • New ringtones, alarms, alerts and system sounds
  • Definitions of a selected word for additional languages: Italian, Korean, and Dutch
  • Inclinometer in the Compass app
  • Wi-Fi HotSpot 2.0 support
  • Accessibility features
    • Individuals with limited physical motor skills can now control their device using Switch Control
    • Customize closed caption style
    • Handwriting input support in VoiceOver
    • Math input support using Nemeth Braille in VoiceOver
    • Select from multiple premium voices for speak selection and VoiceOver 
    • Support for Made for iPhone Hearing Aids and stereo audio for iPhone 5 and iPod touch (5th generation)
  • Enterprise features
    • Manage which apps and accounts are used to open documents and attachments
    • Per App VPN
    • App Store license management
    • Enterprise single sign-on
    • Remote configuration of managed apps
    • Automatic data protection for third-party apps
    • Exchange Notes syncing
    • Install custom fonts
    • New management queries and restrictions
  • Education features
    • Mobile device management for Apple TV
    • Request AirPlay Mirroring from a student device to Apple TV
    • Pre-configure AirPlay destinations and AirPrint printers
    • Streamlined MDM enrollment
    • Ability to restrict changes to accounts
    • Web content filtering
    • Authorized apps can initiate single app mode
    • Configure accessibility settings for single app mode
  • Features for China
    • Tencent Weibo integration
    • Chinese-English bilingual dictionary
    • Improved handwriting input with improved accuracy, stroke order independence and support for simultaneous multiple character input

PS: Some features may not be available for all countries or all areas.

Wednesday, September 18, 2013

TSQL : Strip Special characters from string

Here is how you can strip all special characters from a column. Here I need to remove all special characters from a column before inserting into database. I wrote this function to reuse this in different places.

CREATE FUNCTION dbo.usfStripSpecailCharacters
(
@str VARCHAR(255)
)
RETURNS VARCHAR(255)
AS
BEGIN

WHILE PATINDEX( '%[~,@,#,$,%,&,*,(,),.,]%', @str ) > 0
SET @str = Replace(REPLACE( @str,
SUBSTRING( @str, PATINDEX( '%[~,@,#,$,%,&,*,(,),.,]%', @str ), 1 ),''),'-','')
RETURN @str

END
GO
-- Use this function and pass your string to remove special characters
SELECT dbo.usfStripSpecailCharacters('test#se3#$%#@-32402');
Hope this is useful!!

TSQL: Time in Military Format in 00:00 or 0000 format

Here is a way you can get time in desired military format. I need this to be in 0000 format.

For example If the current time is 12:35 AM, I need to be display this in 1235 in integer format or if you want with 12:35 you can use the following to fulfill your requirement.

DECLARE @time TABLE (
id INT IDENTITY(1, 1),
dt DATETIME)

INSERT INTO @time
VALUES ('7:34:00 PM')

-- time in 24 hour military format
SELECT CONVERT(VARCHAR(5), dt, 114) AS FormatedDT
FROM @time
-- time without colon in military format
SELECT REPLACE(CONVERT(VARCHAR(5), dt, 114),':','') AS FormatedDT
FROM @time

Hope this is useful!!!

Wednesday, September 04, 2013

Missing Send to items in windows 7

Recently I lost few of my icons went missing from Send to folder when we right click on any item or folder. I frequently use Mail Recipient in this. Here is how we can restore this back from default profile

1. Go to following path for default profile setting to capture

"C:\Users\Default\AppData\Roaming\Microsoft\Windows\SendTo" or any other profiles which you have access to from below locations
"C:\Windows\ServiceProfiles\LocalService\AppData\Roaming\Microsoft\Windows\SendTo"
"C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\Windows\SendTo"

2. Now go to run command  or type in start-search box and type shell:sendto to access your own profile.

3. Copy missing files from your default profile to your own profile. If you want you can add  your own short cuts for quick access.

You are good to go now. Hope this helps!!

Tuesday, August 20, 2013

TSQL: DateTime in different formats

Here is how you can convert get date in different formats

SELECT
GETDATE() AS GetDate,
CONVERT(VARCHAR,GETDATE(),0) AS '0',
CONVERT(VARCHAR,GETDATE(),100) AS '100',
CONVERT(VARCHAR,GETDATE(),1) AS '1',
CONVERT(VARCHAR,GETDATE(),101) AS '101',
CONVERT(VARCHAR,GETDATE(),7) AS '7',
CONVERT(VARCHAR,GETDATE(),107) AS '107',
CONVERT(VARCHAR,GETDATE(),108) AS '108',
CONVERT(VARCHAR,GETDATE(),108) AS '108',
CONVERT(VARCHAR,GETDATE(),10) AS '10',
CONVERT(VARCHAR,GETDATE(),110) AS '110',
CONVERT(VARCHAR,GETDATE(),12) AS '12',
CONVERT(VARCHAR,GETDATE(),112) AS '112',
CONVERT(VARCHAR,GETDATE(),14) AS '14',
CONVERT(VARCHAR,GETDATE(),114) AS '114'


You can refer this URL for other formatting options or follow below URL


Find more help  http://www.sql-server-helper.com/tips/date-formats.aspx

Thursday, July 25, 2013

Find all Stored Procedures depending on a Table in Database

We can use sp_depends, sp_depends displays information about database object dependencies, such as the views and procedures that depend on a table or view, and the tables and views that are depended on by the view or procedure

But some times sp_depends does not always return accurate results.

Here is how you can get accurate results by using this query’s below

SELECT DISTINCT o.name, o.xtype
FROM syscomments c
INNER JOIN sysobjects o ON c.id=o.id
WHERE c.TEXT LIKE '%TableName%'


Save results with headers in SQL Server Management Studio

I am working a lot with excel and CSVs for my SSIS packages these days. so I need to some input files as CSV files from SQL Server. Here is what I did in SQL Server Management Studio to get CSV files with Headers
  1. Go to Tools in SQL Server Management Studio and click options.
  2. Now click on Query Results and select SQL Server.
  3. Now go to Results to Grid.
  4. Select “Include column headers when copying or saving the results. (shown in below image)
  5. Click OK
  6. Restart SQL Server Management Studio and you are good to go now.
 image Now open your query window and write you query and execute. On the results window right click and select  "save results as" and then save to CSV file which I can open in excel. 


Getting all Triggers in a Database

Some times you might want to know what are the triggers available across your database. Here is how you can know by using the below query.

-- Displays all Triggers in a Database 
SELECT
[Table] = OBJECT_NAME(o.parent_obj),
[Trigger] = o.[name],
[Type] = CASE WHEN
(
SELECT cmptlevel
FROM master.dbo.sysdatabases
WHERE [name] = DB_NAME()
) = 80 THEN
CASE WHEN
OBJECTPROPERTY(o.[id],
'ExecIsInsteadOfTrigger') = 1 THEN
'Instead Of'
ELSE
'After'
END
ELSE
'After'
END,
[Insert] = CASE WHEN
OBJECTPROPERTY(o.[id],
'ExecIsInsertTrigger') = 1 THEN
'Yes'
ELSE
'No'
END,
[Update] = CASE WHEN
OBJECTPROPERTY(o.[id],
'ExecIsUpdateTrigger') = 1 THEN
'Yes'
ELSE
'No'
END,
[Delete] = CASE WHEN
OBJECTPROPERTY(o.[id],
'ExecIsDeleteTrigger') = 1 THEN
'Yes'
ELSE
'No'
END,
[Enabled?] = CASE WHEN
OBJECTPROPERTY(o.[id],
'ExecIsTriggerDisabled') = 0 THEN
'Enabled'
ELSE
'Disabled'
END
FROM sysobjects o
WHERE OBJECTPROPERTY(o.[id], 'IsTrigger') = 1
-- Comment out the following clause if you need to
-- include system triggers, e.g. those in MSDB
AND OBJECTPROPERTY(o.[id], 'IsMSShipped') = 0
ORDER BY 1,2

Thursday, July 18, 2013

64 అర్ట్స్– (aravai naalugu kaLalu)

It is believed that lord Krishna possesses 64 kinds of arts called "Chausath Kalas".  Kala means performing an art.  Here are the list of 64 అర్ట్స్

61436_499527616745167_1132042074_n

IRCTC Launches SMS/USSD based Mobile Bookings

Railway e-ticket now on mobile
  • IRCTC introduces for the first time a non-internet based ticketing system that will empower masses even in remote areas to use the omnipresent mobile device to make reservations.
  • Millions of rail travellers can now use their mobile phones to book tickets in a simple, convenient and secured manner.
  • It uses simple SMS or menu-based USSD technology which works on all mobile phones and involves no internet and costs very little.
  • The services can be currently availed by IRCTC registered users only.
Advantages of booking IRCTC tickets via mobile
  • No need to stand in long queues or log onto the internet.
  • Simple, reliable and secured.
  • Accessible to any mobile user.
  • Very little charges for accessing the service.
  • Works on all handsets.
  • Simple user guided menu - book tickets, search for stations, trains, availability.

1. USSD based booking through Airtel*

Registration
  • Register for Airtel money by dialing USSD (Unstructured Supplementary Services Data) number *400#.
  • Load cash on this or recharge from any Airtel money outlet.
Booking Flow
  • Dial *400# and select book tickets option.
  • Select Reservation.
  • Enter your IRCTC User ID.
  • Enter the details of ticket (station, train no. date of journey, class etc.).
  • Enter mPIN for authorizing payment through Airtel money.
  • Booking confirmation SMS is sent by IRCTC and same can be used during journey along with valid ID proof..
  • Fare & service charges are debited from your Airtel money account.
  • PG Charges: Currently NIL
  • Agent Service Charges: Currently NIL
  • Helpline No.: 121
  • Helpline Email : 121@airtelmoney.in

2. SMS based booking through 139*

Registration
  • Register your mobile number with IRCTC as well as with your bank.
  • Bank provides MMID (Mobile Money Identifier) & OTP (One Time Password) through IMPS (Immediate Payment Service) option.
  • More than 25 banks are providing IMPS facility. For generating MMID & OTP, visit website: http://www.npci.org.in/impsmerpay10.aspx.)
Booking Flow
  • Generate OTP through your Bank for authorization of payment.
  • Send SMS, in the following syntax, to 139 BOOK <TrainNo><FromStn.Code><ToStn.Code> <TravelDate (DDMM)><Class><Passenger-Name><Age><M/F>
  • You will receive Transaction ID alongwith other details.
  • Make payment through sending an SMS, in the following syntax, to 139 PAY <Transaction ID as received><IMPS><Your MMID as received from the bank><OTP, your one time password as received from the bank for this transaction><IRCTCUserID> and your ticket is booked; confirmation SMS is received on your mobile and same can be used during journey along with valid ID proof.
  • Service is available to all mobile subscribers.
  • SMSes @ Rs 3/- per SMS (2 SMSes are required for each booking).
  • PG charges Rs 5/- for ticket amount < Rs 5000/ and Rs 10/- for ticket amount >= Rs 5000/- (as applicable by bank).
  • Agent Service Charges: NIL
  • Helpline No.: 139
  • Helpline Email : smsticket139@bharatbpo.in

3. SMS based booking through 5676714*

Registration
  • Register your mobile number with IRCTC as well as with m-wallet (http://www.zipcash.in/user/nlogin.aspx)
  • Send SMS, to 5676714, in the following syntax START < irctc user Id > for user authentication (first time only)
Booking Flow
  • Send an SMS to 5676714 to book a ticket in the following syntax: BOOK <From stn.code>,<to stn.code>, <DDMMYY>, <Trainno>,<Class>,<passenger name>,<age>,<M/F>
  • 1. "PAY , MPAY, < m-PIN >" for authorizing payment through MPAY OR
  • 2. "Send <mobileno>,<mmid>,<amount>, <transaction Id>,<OTP>" to your Bank IMPS number.
  • After payment is made booking confirmation is sent to your mobile.
  • SMSes @ Rs 3/- per SMS (2 SMSes are required for each booking).
  • PG Charges: Currently NIL
  • Agent Service Charges: As applicable.
  • Helpline No. : 8882001001
  • Helpline Email : support@saarthii.com

4. SMS based booking through BSNL*

User should have the following:
  • 1. BSNL SIM card installed.
  • 2. Java enabled mobile phone.
  • 3. Andhra Bank Prepaid card.
  • This is a menu driven application where user has to enter the details asked for in simple step-by-step process to get the ticket.
Registration
  • Install the application.
  • Select the Register option to get the mPIN.
Booking
  • Click the icon BSNL Prepaid Card
  • Select Ticketing > Train (IRCTC)
  • Fill up the journey details such as From stn, To Stn, Train No, DOJ, Class, Quota, passenger details.
  • Enter the mPIN to get the ticket information.
  • SMSes: without charges.
  • PG Charges: Currently NIL
  • Agent Service Charges: As applicable.
  • Helpline No. : 040-39849644
  • Helpline Email : bsnl.support@pyrogroup.com

Disclaimer : The above details are sent on behalf of IRCTC to their customers. I have coped the same email in this blog to make it available for all the public whom it might be useful for quick reference.

How to get username from email address c#

Here is sample code snippet that I have used to get username from the email address. You can use MailAddress Class to get few built in properties for our use.

   1: string FromEmail = ConfigurationManager.AppSettings["NotifyEmail"].ToString();
   2: MailAddress FromAddress = new MailAddress(FromEmail);
   3: objEmail.From = FromAddress;
   4:  
   5: NetworkCredential NetworkCredential = new NetworkCredential(FromAddress.Address, "XXXXXXX");
   6: smtpclient.Credentials = NetworkCredential;
   7:  
   8: // Alternately you want you can try few different properties from MailAddress class.
   9:  
  10: Debug.WriteLine("DisplayName:  " +  FromAddress.DisplayName);
  11: Debug.WriteLine("Host:  " + FromAddress.Host);

This worked for my scenario. Happy coding.

Monday, July 15, 2013

Telugu Alphabets

Many of us tend to forget our own mother tongue with growing globalization or with the dominance of English being more used as communication medium. Here is what I thought should be useful for at least people like me to remember our own alphabets during the course of time.

I have captured from one of Facebook page where I thought sharing would help few of us Smile

Here are the Telugu alphabets

telugu alphabets

PS: I have copied this for the sake of my own repository. No offence or what so ever.

Download Microsoft SQL Server 2014 CTP

Microsoft has announced its most awaited version of SQL SERVER 2014 for Community Preview. The availability of the first public Community Technology Preview (CTP) of SQL Server 2014.

Here are key features of SQL Server 2014:

    • Mission critical performance across all database workloads with in-memory for online transaction processing (OLTP), data warehousing and business intelligence built-in as well as greater scale and availability
    • Hybrid cloud platform enabling organizations to more easily build, deploy and manage database solutions that span on-premises and cloud
    • Faster insights from any data with a complete BI solution using familiar tools like Excel

You can find more information from Microsoft blog here.

SQL SERVER 2012 Express version

Are you working on SQL Server 2005 or 2008 servers. Here is SQL Server 2012 Express version for download

Microsoft® SQL Server® 2012 Express is a powerful and reliable free data management system that delivers a rich and reliable data store for lightweight Web Sites and desktop applications.

Wednesday, June 05, 2013

How to Validate Date based on format “MM/dd/YYYY” in VB.NET

Here is the sample code snippet which I wrote to do date validation for a particular format and culture.

   1: Private Function validateDateFormat(ByVal strDate As String) As Boolean
   2:     Dim isValid As Boolean = True
   3:     Dim provider As CultureInfo = CultureInfo.GetCultureInfo("en-us")
   4:     Dim formats As String = "d" '"MM/dd/yyyy"
   5:     Dim dateValue As DateTime
   6:     Try
   7:         If DateTime.TryParseExact(strDate, formats, provider, DateTimeStyles.None, dateValue) Then
   8:             isValid = True
   9:         Else
  10:             isValid = False
  11:         End If
  12:     Catch ex As Exception
  13:  
  14:     End Try
  15:     Return isValid
  16: End Function


You can change the formats and CultureInfo to your own custom information. Here is my pervious blog which describes how formatting date time can be done using string object.

Monday, June 03, 2013

How to Kill Excel Ghost Process in SSIS using VB.NET

Here is the simple method to kill Excel Ghost process which is running behind scene while running SSIS package. Here is a small method to kill Excel process if we know the excel caption or excel title we want to close.
Code snippet of the method to kill Excel process
Private Sub KillExcellProcess(ByVal excelCaption As String)
Dim proc As System.Diagnostics.Process
For Each proc In System.Diagnostics.Process.GetProcessesByName("EXCEL")
If (proc.MainWindowTitle = excelCaption) Then
proc.Kill()
End If
Next
End Sub

Use this method in SSIS script task to kill the Excel Ghost process by calling this method in your code
 
Dim xlApp As Excel.Application
Dim xlBook As Excel.WorkbookClass
xlApp = CType(CreateObject("Excel.Application"), Excel.Application)
xlApp.Visible = False
xlApp.DisplayAlerts = False
' Once done with excel stuff and when you want
' to kill excel use the below lines of code
Dim sCaption As String
sCaption = xlApp.Caption
KillExcellProcess(sCaption)
 
Hope this helps!!

How to Kill specific Excel Ghost Process generated in SSIS using VB.NET

There are some scenarios where we might need to kill excel process programmatically.  Even though we use proper error handling and try catch to clear all excel objects still the excel ghost process remains in usage. So for these cases we might need to kill the excel process generated in SSIS package by identifying its process.   Here is how we can kill specific excel process by getting the process id of the excel that is been generated by SSIS package in script task. Refer to my previous blog for kill process by its name
<Runtime.InteropServices.DllImport("user32.dll")> _
Private Shared Function EndTask(ByVal hWnd As System.IntPtr) As Integer
End Function
<Runtime.InteropServices.DllImport("user32.dll")> _
Private Shared Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
End Function
<Runtime.InteropServices.DllImport("kernel32.dll")> _
Private Shared Function SetLastError(ByVal dwErrCode As Integer) As IntPtr
End Function
<Runtime.InteropServices.DllImport("user32.dll", SetLastError:=True)> _
Private Shared Function GetWindowThreadProcessId(ByVal hWnd As System.IntPtr, ByRef lpdwProcessId As Integer) As Integer
End Function

Public Sub EnsureProcessKilled(ByVal MainWindowHandle As System.IntPtr, ByVal Caption As String)
SetLastError(0)
' for Excel versions <10, this won't be set yet
If System.IntPtr.Equals(MainWindowHandle, System.IntPtr.Zero) Then
MainWindowHandle = FindWindow(Nothing, Caption)
End If
If System.IntPtr.Equals(MainWindowHandle, System.IntPtr.Zero) Then
Return
End If
' at this point, presume the window has been closed.
Dim iRes As Integer = 0
Dim iProcID As Integer = 0
iRes = GetWindowThreadProcessId(MainWindowHandle, iProcID)
' can?t get Process ID
If iProcID = 0 Then
If EndTask(MainWindowHandle) <> 0 Then
Return
End If
' success
Throw New ApplicationException("Failed to close.")
End If
Dim proc As System.Diagnostics.Process = Nothing
proc = System.Diagnostics.Process.GetProcessById(iProcID)
proc.CloseMainWindow()
proc.Refresh()
If proc.HasExited Then
Return
End If
proc.Kill()
End Sub

Use this method in SSIS script task to kill the Excel Ghost process by calling this method in your code
 
Dim sVer As String
sVer = xlApp.Version
Dim iHandle As IntPtr = IntPtr.Zero
If Val(Convert.ToDouble(sVer)) >= 10.0 Then
iHandle = New IntPtr(CType(xlApp.Parent.Hwnd, Integer))
End If
'To kill process created by this job by process id
EnsureProcessKilled(iHandle, xlApp.Caption)


Hope this help!!

How do I format date value as yyyymmdd or any specific using SSIS expression builder?

I have a scenario where I need to create a folder on fly with current date in YYYYMMDD format.

Here is simple solution how we can achieve using Expression Builder in SSIS packages. Pick the variable that’s needs to be configured.

Go to properties of the variable you want to configure and click expression.

A Popup window will appear where you can select the variable you want to configure

Select the property you want to override. For me its Destination path property of the Source folder variable I am using in my package.

C:\Development\XXXXX\XXXXX\20130516\

Here is code that needs to append to the variable. So here is what I have used to get this in below format. 
(DT_STR,4,1252)DATEPART( "yyyy" , getdate() ) + 
RIGHT("0" + (DT_STR,4,1252)DATEPART( "mm" , getdate() ), 2) +
RIGHT("0" + (DT_STR,4,1252)DATEPART( "dd" , getdate() ), 2)


clip_image002
 For me its yyyymmdd format if you want some other format just change the interval one of the following this as per your requirement
  • yyyy – Year
  • q – Quarter
  • m – Month
  • y - Day of year
  • d – Day
  • w – Weekday
  • ww - Week of year
  • h – Hour
  • n – Minute
  • s - Second
Hope this helps!!!

Saturday, April 20, 2013

How to Remove Css Style from codebehind?

Here is how we can achieve this from codebhind in c#. Here is the sample code snippet I am here removing CssSytle from DIV but I works for any Control

   1: // Removing Div class when we have only transaction details
   2: divTransactionSummary.Attributes.Add("class", divTransactionSummary.Attributes["class"].ToString().Replace("prodiv", ""));
   3:               

Here “prodiv” is the class of div I have used in my aspx page for this DIV


Hope this helps!!

Sunday, March 31, 2013

iPad Supported Video Formats

I got my first iPad and I am trying to know about that are the Video formats that are supported by iPad devices.

Here is the list

  • H.264 video up to 720p, 30 frames per second, Main Profile level 3.1 with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats.
  • MPEG-4 video, up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 Kbps per channel, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats.
  • Motion JPEG (M-JPEG) up to 35 Mbps, 1280 by 720 pixels, 30 frames per second, audio in ulaw, PCM stereo audio in .avi file format.

I found this information via google. Thought this worth sharing.

Saturday, March 23, 2013

SMTP Server Error: Bad sequence of commands. The server response was: you must authenticate first (#5.5.1)

This error occurs due to lock down of default mail server (127.0.0.1) by web hosting companies due to SPAM or what ever other security reasons. But if you use “localhost” or default server “127.0.0.1” on your local machine it should not be an issue. But if you have a situation where you need to relay e-mail to a remote mail server that is secured you get this exception.

So you need to handle well using built in classes provided by .NET. This is take care by NetworkCredential Class. This class provides credentials for password-based authentication schemes such as basic, digest, NTLM, and Kerberos authentication.

Here is a fully working quick code sample that you can use to get started on your own SMTP-Authentication supporting e-mail code.

   1: try
   2: {
   3:     SmtpClient smtpclient = new SmtpClient();
   4:     NetworkCredential NetworkCredential = new NetworkCredential(smtpUserName, smtpPassword);
   5:     smtpclient.Credentials = NetworkCredential;
   6:     string MailServer = ConfigurationManager.AppSettings["SMTPServer"].ToString();
   7:     MailMessage objEmail = new MailMessage();
   8:  
   9:     string FromEmail = ConfigurationManager.AppSettings["ErrorReportEmailFrom"].ToString();
  10:     if (FromEmail.IndexOf(";") > 0)
  11:     {
  12:         FromEmail = FromEmail.Replace(";", ",");
  13:     }
  14:     MailAddress FromAddress = new MailAddress(FromEmail);
  15:     objEmail.From = FromAddress;
  16:  
  17:     string ToEmail = ConfigurationManager.AppSettings["ErrorReportEmailTo"].ToString();
  18:     if (ToEmail.IndexOf(";") > 0)
  19:     {
  20:         ToEmail = ToEmail.Replace(";", ",");
  21:     }
  22:     objEmail.To.Add(ToEmail);
  23:  
  24:     string CcEmail = ConfigurationManager.AppSettings["CcEmail"].ToString();
  25:     if (CcEmail.IndexOf(";") > 0)
  26:     {
  27:         CcEmail = CcEmail.Replace(";", ",");
  28:     }
  29:     objEmail.CC.Add(CcEmail);
  30:  
  31:     string BccEmail = ConfigurationManager.AppSettings["BccEmail"].ToString();
  32:     if (BccEmail.IndexOf(";") > 0)
  33:     {
  34:         BccEmail = BccEmail.Replace(";", ",");
  35:     }
  36:     objEmail.Bcc.Add(BccEmail);
  37:  
  38:     objEmail.Subject = strSubject;
  39:     try
  40:     {
  41:         objEmail.Body = strBody;
  42:         objEmail.IsBodyHtml = true;
  43:         smtpclient.Host = MailServer;
  44:         smtpclient.Send(objEmail);
  45:     }
  46:     catch (Exception ex)
  47:     {
  48:         throw ex;
  49:     }
  50:     finally
  51:     {
  52:         objEmail.Dispose();
  53:     }
  54: }
  55: catch (Exception ex)
  56: {
  57:      
  58: }

Enjoy coding!!