Thursday, November 25, 2010

UINavigationController back button custom text

To Change the back button text we need to give in viewDidApper. If you give in viewDidLoad it not work.

- (void)viewDidAppear:(BOOL)animated {
self.navigationController.navigationBar.backItem.title=@"Back";
}


Tuesday, October 5, 2010

To enable remote connections on SQL Server 2005

To enable remote connections on the instance of SQL Server 2005 and to turn on the SQL Server Browser service, use the SQL Server 2005 Surface Area Configuration tool. The Surface Area Configuration tool is installed when you install SQL Server 2005.


  • Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Surface Area Configuration





  • Click Surface Area Configuration for Services and Connections. It gives the following screen.





On the Surface Area Configuration for Services and Connections page, expand Database Engine, click Remote Connections, click Local and remote connections, click the appropriate protocol to enable for your environment, and then click Apply.


On the Surface Area Configuration for Services and Connections page, expand Database Engine, click Service, click Stop, wait until the MSSQLSERVER service stops, and then click Start to restart the MSSQLSERVER service.

Enable the SQL Server Browser service

If you are running SQL Server 2005 by using an instance name and you are not using a specific TCP/IP port number in your connection string, you must enable the SQL Server Browser service to allow for remote connections. For example, SQL Server 2005 Express is installed with a default instance name of Computer Name\SQLEXPRESS. You are only required to enable the SQL Server Browser service one time, regardless of how many instances of SQL Server 2005 you are running. To enable the SQL Server Browser service, follow these steps.



On the Surface Area Configuration for Services and Connections page, click SQL Server Browser, click Automatic for Startup type, and then click Apply.











Check the firewall if you are enabled the sqlservr.exe and sqlbrowser.exe.
You may need to create an exception on the firewall for the SQL Server instance and port you are using

  • Start > Run > Firewall.cpl

  • Click on exceptions tab

  • Add the sqlservr.exe (typically located in C:\Program Files (x86)\Microsoft SQLServer\MSSQL.x\MSSQL\Binn),

  • Add the sqlbrowser.exe(typically located in C:\Program Files\Microsoft SQL Server\90\Shared\sqlbrowser.exe)

Monday, September 20, 2010

Error:The model used to open the store is incompatible with the one used to create the store(in iphone/iPad)

When i was working with coredata first it runs perfect after i change the the data model,my program got crashed.

To solve this problem:
  • Delete your previous builds completely.
  • Delete the app in simulator also
Now build the application and run it its work fine now.

Wednesday, September 1, 2010

Border and Rounded corners the UIImage

To border the UImage is Simple way

Bofore adding the Code import QuartzCore  (#import <QuartzCore/QuartzCore.h>)

UIImage *MyImage=[UIImage imageNamed: @"baby.jpg"];

MyImage.layer.borderColor = [UIColor lightGrayColor].CGColor;


MyImage.layer.borderWidth = 2.0;
To add Corner radius for the same image just add below two lines

MyImage.layer.cornerRadius = 10.0;

MyImage.layer.masksToBounds = YES;

Sunday, August 29, 2010

Remove the Duplicate Rows in DataTable

Removing the Duplicate Rows in DataTable in C# is simple.

Best way is use DISTINCT Keyword in Database Query, but some times we may fill the data manually.

We can remove by using two type

First One is very simple and it is used when we need to compare all columns in the rows.
DataTable _NewTable=_Table.DefaultView.ToTable(true);
Second, Suppose we need to remove the rows for specific columns only means then we can go for the following Method
List<string> keyColumns = new List<string>();
keyColumns.Add("Column1");
keyColumns.Add("Column2");
RemoveDuplicatesFromDataTable(ref _Table, keyColumns);

public void RemoveDuplicatesFromDataTable(ref DataTable table, List<string> keyColumns)

{
Dictionary<string, string> uniquenessDict = new Dictionary<string, string>(table.Rows.Count);
StringBuilder stringBuilder = null;
int rowIndex = 0;
DataRow row;
DataRowCollection rows = table.Rows;
while (rowIndex < rows.Count - 1)
{
row = rows[rowIndex];
stringBuilder = new StringBuilder();
foreach (string colname in keyColumns)
{
stringBuilder.Append(((string)row[colname]));
}
if (uniquenessDict.ContainsKey(stringBuilder.ToString()))
{
rows.Remove(row);
}
else
{
uniquenessDict.Add(stringBuilder.ToString(), string.Empty);
rowIndex++;
}
}
}



Tuesday, August 24, 2010

Disabling the selection in UITableView.

To disable the selection in UITableView use the following code
cell.selectionStyle = UITableViewCellSelectionStyleNone;
or


[cell setSelectionStyle:UITableViewCellSelectionStyleNone];

Sunday, August 15, 2010

How to Enabling PHP on Mac Leopard

To Enable PHP(note: before that enable Apache server)
  1. Open the Terminal.
  2. Type cd /etc/
  3. then type sudo cp php.ini.default php.ini
  4. After that type cd /private/etc/apache2/
  5. uncomment the two modules: php5_module and fastcgi_module. (Remove #). Search for php5_module.
  6. Then Save by ctrl and o
  7. Then reload the Apache server

Tuesday, August 10, 2010

Setting Background image or color for UITableView in IPhone

Hi,
Now, we are going to see how to set the background color or image for UITableView.
To set the Background color or image for UITableView set the background for parentview of the tableview and set the background color as clearcolor this shows the transparent color to so the parentview background.

The following code is for setting background image for tableview 

self.parentViewController.view.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"tvbg.png"]];
self.tableView.separatorColor=[UIColor clearColor];
self.tableView.backgroundColor=[UIColor clearColor];

Friday, July 30, 2010

Drawing in iPhone

Now, I am going to explain how to draw in iPhone.


For drawing we can use touch events (touchBegin and touchMoved).
First,create a View Based Application.
And then Add a new class which inherits from uiimageview, name of class be "MyImageView"
After that in MyImageView.h, add a CGPoint to store the starting Point and NSstring to to knoe the brush is for Drawing or Erasing.


MyImageView.h file look like








And in implemation File(MyImageView.m) look like






To Download complete project  Sample Code here

Friday, July 9, 2010

Draggable or Movable Image in iPhone

Hi,
I am going to tell how to create a draggable Image in iphone application


First, create a view-based application and name it as your wish for my application i am creating with name MyDragApp. It creates a MyDragAppAppDelegate.h & .m, MyDragAppViewController.h &.m files.


Now add a new file for moving the image, it should inherits the UIImageView,


DraggableImage.h

@interface DraggableImage : UIImageView {
CGPoint startPoint;
 }

@end


For moving the Image we are going to use the "touchesBegan and touchesMoved" Delegate.

DraggableImage.m
#import "myDraggable.h"



@implementation myDraggable
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
// Retrieve the touch point
CGPoint pt = [[touches anyObject] locationInView:self];
startPoint = pt;

}

- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
// Move relative to the original touch point
CGPoint pt = [[touches anyObject] locationInView:self];
CGRect frame = [self frame];
frame.origin.x += pt.x - startPoint.x;
frame.origin.y += pt.y - startPoint.y;
[self setFrame:frame];
}
@end



After that Create an object for that DraggableImage in Main View and then setUserInteractionEnabled:YES for that object and added to ur view and then run your application to Drag the Image


MyDragAppViewController.m

#import "MyDragAppViewController.h"
#import "DraggableImage.h"

@implementation MyDragAppViewController

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
DraggableImage *dragImage=[[DraggableImage alloc]
  initWithImage:[UIImage imageNamed:@"baby-1.jpg"]];
[dragImage setUserInteractionEnabled:YES];
[self.view addSubview:dragImage];
[dragImage release];
}

- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

- (void)dealloc {
    [super dealloc];
}
@end



To Download the Project Click Here

Wednesday, June 30, 2010

Zooming and Scrolling in UIScrollView(iphone Application)

Hi,
When i was learning how to use UIScrollview for a controls like image or label. Scrolling is not worked properly so i google for it then i finally found then we need to give contentsize above the scrollview height and width.


Following code gives you image zooming and scrolling.
  1. First create a navigation based application or create a window based application in .h file declare the UIScrollView and UIImageview and add the scrollviewdelegete to zoom the image
#import
@interface ScrollingImage : UIViewController
{
UIScrollView *scrollView;
UIImageView *imageView;
}
@property (nonatomic, retain) UIScrollView *scrollView;
@property (nonatomic, retain) UIImageView *imageView;
@end


    2) In .m file synthesize the scrollView and imageView and in dealloc delegate release them both.


#import "ScrollingImage.h"


@implementation ScrollingImage
@synthesize scrollView, imageView;


- (void)dealloc {
    [super dealloc];
[imageView release]; [scrollView release];
}

//To zoom

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
return imageView;
}


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Lighthouse.jpg"]]; self.imageView = tempImageView;
tempImageView.frame = CGRectMake(0, 0, 320, 370); scrollView.pagingEnabled = NO; scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0,0,320, 370)];
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width + 150 , scrollView.frame.size.height + 150); scrollView.maximumZoomScale = 10.0; scrollView.minimumZoomScale = 1; scrollView.delegate = self; scrollView.scrollsToTop = NO; scrollView.backgroundColor = [UIColor whiteColor]; scrollView.showsHorizontalScrollIndicator=YES; scrollView.showsVerticalScrollIndicator=YES; [scrollView addSubview:imageView]; [self.view addSubview:scrollView]; [tempImageView release];
}


Now build and go in the simulator to run the application.

Friday, June 18, 2010

jQuery equivalent for document.getElementById("") in javascript

Hi,


When i am trying to write the client validation i used document.getElementById("") to get the value of the control and then validate that and return the result. So, when i move on to jQuery i try to figured out what would be the equivalent code for that i tried


var _Text = $("#controlid").value; //to get the content


but i didn't get the content. So after i browsed in the google and found the $("") ,selector, in jQuery the array so we need to use the array bracket or get method to get the content of the control.


var _Text = $("#controlid")[0].value
or
var _Text = $("#controlid").get(0).value

Sunday, June 13, 2010

Run the database script while running the setup

Hi,

When i am developing a product, i asked myself did i need to run the script after i installed the setup? is there any other way to run the script while i running the setup.

After a long search i found some results but i dont get any complete result for my search so i am post this hope it helps you...

Now i am going to run the script using VBScript.

Open the text editor like notepad

type the following code and save the file with extension .vbs
Dim cn
Set cn = CreateObject("ADODB.Connection")


cn.Open "Provider=SQLOLEDB;Data Source=.\SQLEXPRESS;Initial Catalog=master;Integrated Security=True;Integrated Security=SSPI;"

//This checks is their any database with this name.IF not it create the database.
cn.Execute "if not exists(select * from sys.databases where name = 'databasename') create database databasename"


cn.Execute "Use databasename"

//Then your regular scripts for creating table and stored procedure..


After saved this file add the file to you project.

select the setup and deployment project. Right click on the project from that menu select View--> Custom action



After that add custom action



It display the dialog box 


  • Double click the Application Folder.
  • In that you already added the output of the project,in addition with add the Script.vbs file.
  • Click ok and built the project and now you can run the script before run the setup file.

(Add the prerequisites as SQLexpress edition this will check whether it has sql server database before running the script otherwise you get the error message)

Software Development Cycle

I like it, so i am posting





Software doesn’t just appear on the shelves by magic. That program shrink-wrapped inside the box along with the indecipherable manual and 12-paragraph disclaimer notice actually came to you by way of an elaborate path, through the most rigid quality control on the planet. Here, shared for the first time with the general public, are the inside details of the program development cycle.
1. Programmer produces code he believes is bug-free.
2. Product is tested. 20 bugs are found.
3. Programmer fixes 10 of the bugs and explains to the
testing department that the other 10 aren't really bugs.
4. Testing department finds that five of the fixes didn't
work and discovers 15 new bugs.
5. See 3.
6. See 4.
7. See 5.
8. See 6.
9. See 7.
10. See 8.
11. Due to marketing pressure and an extremely pre-mature
product announcement based on overly-optimistic programming
schedule, the product is released.
12. Users find 137 new bugs.
13. Original programmer, having cashed his royalty check, is
nowhere to be found.
14. Newly-assembled programming team fixes almost all of the
137 bugs, but introduce 456 new ones.
15. Original programmer sends underpaid testing department a
postcard from Fiji. Entire testing department quits.
16. Company is bought in a hostile takeover by competitor using
profits from their latest release, which had 783 bugs.
17. New CEO is brought in by board of directors. He hires programmer
to redo program from scratch.
18. Programmer produces code he believes is bug-free....




Original content is taken form below
http://linkegypt.com/blog/2010/03/27/65/