January 2012 | Coding Cluster - using asp.net, c#, mvc 4, iphone, php, ios, javascript, in asp.net mvc 3 & more

How to remove duplicate rows from a table in SQL Server


Remove Duplicate Rows from a Table in SQL Server:
                    Duplication rows in database tables will exists by running the data repeatedly With out  having the primary key on table. Here is an example to remove the duplicate records  from a table in SQL Server


DELETE FROM Employee emp1 WHERE ROW_NUMBER()<>(SELECT MIN( ROW_NUMBER())FROM       EMployee emp2 WHERE emp1.empname= emp2.empname) 

Please share this post if it's useful to you. Thanks!.

ASP.NET:How to write error messages into a text file


Create log file in asp.net using C#:
                                       .NET have a various classes to create, write  on a text file which are file .Here I'm using create() method to create a text file and using some classes to reading and writing text files those are TextReader,StreamReader,StreamWriter,TextWriter classes.These are abstract classes .Here i have taken a logfilepath which is the physical path of the text file.If the file is existing in path then we will write message into this text file.If the file is not existing in the path then we will create a file in this path and write a (log) messages into it


public static string strPath = AppDomain.CurrentDomain.BaseDirectory;
public static string strLogFilePath = strPath + @"log\log.txt";
public static void WriteToLog(string msg)
    if (!File.Exists(strLogFilePath))
    using (StreamWriter w = File.AppendText(strLogFilePath))
        w.WriteLine("\r\nLog: ");
        string err = "Error Message:" + msg;
Please share this post if it's useful to you. Thanks!.

IPhone - Keyboard Return button not responding

How to hide keyboard for UITextView with return key?-IPhone:
                                            The following three simple steps is used to dismiss the keyboard for UITextView while clicking return key.
         Subscribe to the UITextFieldDelegate Protocol in your View/ViewController's header file like:           
YourViewController : UIViewController <UITextFieldDelegate>

        Setyour view/viewcontroller to be the UITextField's delegate after you init the textfield in the .m:
.delegate = self;
        Then in your .m file you need to implement the following UITextFieldDelegate protocol method:

        - (BOOL)textFieldShouldReturn:(UITextField *)theTextField
              [theTextField resignFirstResponder];
              return YES;
That's all.  If this post was useful to you please send your valuable comments

How do I delete a file from documents directory? - IPhone


iPhone sdk – Delete Files in the Documents Directory:
                                           This id the code for delete files from iphone's  Documents directory. In this example I've deleting a file from document's sub directory in iPhone (media_1). I'm using this code to delete an image from the media_1 directory and it,'s works well.

// Get the Documents directory path
NSString *temPath = [NSString stringWithFormat:@"%@%d",@"Documents/Media_", Key_mediaID];
//This temPath look line ../../../Documents/Media_1

 NSString *documentsDirectoryPath = [NSHomeDirectory() stringByAppendingPathComponent:temPath];

// Delete the file using NSFileManager
 NSFileManager *fileManager = [NSFileManager defaultManager];
 [fileManager removeItemAtPath:[documentsDirectoryPath stringByAppendingPathComponent:Your File Name] error:nil];

How to Uninstall Xcode


How to remove iPhone sdk:

Run the following from within a terminal window to remove Xcode and existing SDK.
sudo /Developer/Library/uninstall-devtools –mode=all

how to split a string - iPhone


How to split items in a string separated by comma:
                                                         You can split a string by  using NString's componentsSeparatedByString method in iphone sdk.

 NSString *strPasscode = @"A,B,C,D";  
 NSArray *arr = [strPasscode componentSeparatedBy:@","];  
 passcodeTxt1.text = [arr objectAtIndex:0];  
 passcodeTxt2.text = [arr objectAtIndex:1];
 passcodeTxt3.text = [arr objectAtIndex:2];
 passcodeTxt4.text = [arr objectAtIndex:3];




Blogger Widgets