Tuesday, October 23, 2012

[SQL] How to access remote data in a Transact-SQL

I was facing an issue with a friend of mine who need to perform a select statement that selects data from a remote SQL instance.

All  I was thinking about is how to use something like connection string on the execute command to have a permission that could be used to connect to the remote server.

I found that I might use the following syntax:
 OPENDATASOURCE ( provider_name, init_string )
where,

provider_name
Is the name registered as the PROGID of the OLE DB provider used to access the data source. provider_name is a char data type, with no default value.

init_string
Is the connection string passed to the IDataInitialize interface of the destination provider. The provider string syntax is based on keyword-value pairs separated by semicolons, such as: 'keyword1=value; keyword2=value'

In order to use OPENDATASOURCE for connection I found that OPENDATASOURCE can be used to access remote data from OLE DB data sources only when the DisallowAdhocAccess registry option is explicitly set to 0 for the specified provider, and the Ad Hoc Distributed Queries advanced configuration option is enabled. When these options are not set, the default behavior does not allow for ad hoc access.

The OPENDATASOURCE function can be used in the same Transact-SQL syntax locations as a linked-server name. Therefore, OPENDATASOURCE can be used as the first part of a four-part name that refers to a table or view name in a SELECT, INSERT, UPDATE, or DELETE statement, or to a remote stored procedure in an EXECUTE statement. When executing remote stored procedures, OPENDATASOURCE should refer to another instance of SQL Server. OPENDATASOURCE does not accept variables for its arguments.

Like the OPENROWSET function, OPENDATASOURCE should only reference OLE DB data sources that are accessed infrequently. Define a linked server for any data sources accessed more than several times. Neither OPENDATASOURCE nor OPENROWSET provide all the functionality of linked-server definitions, such as security management and the ability to query catalog information. All connection information, including passwords, must be provided every time that OPENDATASOURCE is called.

I used the following testing procedure and it works:


sp_configure 'show advanced options', 1;
RECONFIGURE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
GO
select *
from opendatasource('SQLOLEDB.1','Data Source=xxxxx;Password=xxxxx;User ID=xxxxx;Initial Catalog=DATABASE_NAME').[DATABASENAME].[dbo].[TABLE_NAME]


As you see, in order to enable 'Ad Hoc Distributed Queries', you have at first to enable 'show advanced options'.

Hope it could help :)

Thursday, August 30, 2012

Software Development Crises Management


On this post, I am going to talk about how to manage a crises inside a software development project.

In order to manage a crisis, you have to know at first that there is a problem. Knowing that there is or there will be a problem is the first step to get it solved.

There hasn’t ever been any project that didn’t have a crisis, and yours is not going to be an exception. So you cannot avoid having a crisis, but you have to be able to manage them.

1. Customer should be notified as early as possible of the delay

One of the most recurrent situations where expectations need to be managed is when a project is going to be late. What usually happens when the project is late is that the customer is not told about that because the project manager hopes that the deviation can be corrected or because being afraid of disappointing the client. 

What more often happens is that the customer is told too late of the delay, when there’s no other option, and what it could have been a minor, or not so big issue by managing the expectations and postponing the deadline or the scope of the release, becomes a major issue that sometimes puts at risk the entire project.

2. Project Manager have to listen to developers

In software development, programmers are the only source of productivity, and for that reason, there is nothing more important than making sure that they have what they need to do their job.

Unfortunately many project managers prefer to focus on dates, meetings and deadlines, which sometimes is good as it makes the project move forward, but sometimes developer feedback is overlooked causing productivity issues, technical debt, low quality products, etc.


3. Be Transparent

Managing a project is to take responsibility when things go wrong and making sure that all the stakeholders are well informed of what is the current status of the project. Hiding information is never good in the long run.
Unfortunately, one of the most difficult activities is to learn what the real status of the project is. There are many projects that died because it was discovered too late that the project was heading the wrong direction and it was too late.

4. Manage uncertainty

Project uncertainty should be specified on the project -it is called Epics- even if you do not know how to release this uncertainty on the beginning of the project, but it should be identitfied and given a weight to be resolved.

5. Have an Emergency Plan

Every project should have an emergency plan, you need to know who, how and when can be contacted in case of emergency and what availability they are supposed to have. There is nothing that can fully prevent you from having a crisis, os when they do appear, you have to react accordingly.

6. Stop being most of the time under pressure.

When you spend too much time under a high quantity of pressure you will start becoming less productive.

References:

Wednesday, August 15, 2012

Microsoft free Productivity Power Tools

Today, I was reading an article in Visual Studio Magazine. It was representing a guided tour inside Visual Studio 11 from an IDE perspective.

I found that there's a set of IDE productivity improvements that developers across all platforms and languages will notice. Many of these enhancements were available in an update for Visual Studio 2010 under the name 'Productivity Power tools'.

I was really fascinated about the enhancements and was wondering how I did not catch it before!

I installed it and I found that it adds a value to me ,so that I would like to share it to everyone - who might be like me - to use it if he did not.

You could download it (it is 1.37 MB) and read about IDE improvements by clicking here.

Wednesday, July 18, 2012

Technical Debt

Technical debt (also known as design debt or code debt) is a neologistic metaphor referring to the eventual consequences of poor or evolving software architecture and software development within a codebase.


No matter how comfortable a schedule looks at the beginning of an iteration, you can't avoid being under pressure some of the time. 
If you find yourself having to choose between "doing it right" and "doing it quick" it is often appealing to "do it quick" on the understanding that you'll come back and fix it later. 


When you make this promise to yourself, your team, and your customer, you mean it. But all too often the next iteration brings new problems or requirements and you become focused on them. 


This sort of deferred work is known as technical debt and it is not your friend, it is a monster that will -on most of the cases- win!


Technical Debt is a wonderful metaphor developed by Ward Cunningham to help us think about this problem. 


In this metaphor, doing things the quick and dirty way sets us up with a technical debt, which is similar to a financial debt. Like a financial debt, the technical debt incurs interest payments, which come in the form of the extra effort that we have to do in future development because of the quick and dirty design choice. We can choose to continue paying the interest, or we can pay down the principal by re-factoring the quick and dirty design into the better design. Although it costs to pay down the principal, we gain by reduced interest payments in the future.


The metaphor also explains why it may be sensible to do the quick and dirty approach. Just as a business incurs some debt to take advantage of a market opportunity developers may incur technical debt to hit an important deadline. The all too common problem is that development organizations let their debt get out of control and spend most of their future development effort paying crippling interest payments.


Steve McConnell has a lengthy blog entry examining technical debt. The perils of not ackowledging your debt are clear:


One of the important implications of technical debt is that it must be serviced, i.e., once you incur a debt there will be interest charges. If the debt grows large enough, eventually the company will spend more on servicing its debt than it invests in increasing the value of its other assets. A common example is a legacy code base in which so much work goes into keeping a production system running (i.e., "servicing the debt") that there is little time left over to add new capabilities to the system. With financial debt, analysts talk about the "debt ratio," which is equal to total debt divided by total assets. Higher debt ratios are seen as more risky, which seems true for technical debt, too.




The tricky thing about technical debt that is unlike money is that it's impossible to measure it effectively. The interest payments hurt a team's productivity, but since we cannot measure productivity, we can't really see the true effect of our technical debt.


References:
http://en.wikipedia.org/wiki/Technical_debt


http://www.javacodegeeks.com/2010/12/things-every-programmer-should-know.html


http://www.codinghorror.com/blog/2009/02/paying-down-your-technical-debt.html


http://martinfowler.com/bliki/TechnicalDebt.html


http://faheemsohail.com/2011/03/scrum-and-xp-go-hand-in-hand/

Tuesday, April 3, 2012

TFS Server 2010 - Change Server IP problem

It was a problem that makes me mad, but finally I get it :)
I have looked over the whole internet to find a solution without an answer ,so I hope I could help anyone who meets the same problem ...


I have changed TFS server IP and I do not want to re-map all projects again as there are checked out items that I do not want to lose, specially that the projects are too much to keep track or to apply the changes again.


For not talking too much let's find the solution steps:


1) Make sure that the solution file .sln are not read only. You can Just uncheck Read only in file properties.


2) Edit solution file .sln in notepad. Change from SccTeamFoundationServer = http://192.168.3.184:8080/ to SccTeamFoundationServer = http://129.168.3.91:8080/ (I mean here changing from TFS old IP to new IP)then save the file. 


3) Move to the following path and remove all files on it : C:\Users\[USER]\AppData\Local\Microsoft\Team Foundation\3.0\Cache


where [USER] is the desktop user.


4) From Team Explorer add the new server.


5) Open the solution and go online :)


Hope it helps

Wednesday, March 14, 2012

Use PreviousPageType to Simplify Page Data Access

In ASP.NET you can request another page either through cross-page posting, or through a Server.Transfer. You can then access the previous page and read accessible page properties.


However, the PreviousPage property returns a Page object; so, to access this property in the target page, you need to cast the PreviousPage property to the previous page's type.



You can pass that information onto ASP.NET by adding the PreviousPageType directive to the aspx file of the target page. This allows ASP.NET to strongly type the PreviousPage property in the target page so no need for casting.



The PreviousPageType directive can be added to the asp.net page to be like:
<%@ PreviousPageType VirtualPath="~/Hotel.aspx" %>


and in the source code you could access HotelId property in Hotel.aspx page by writing:
long hotelId = PreviousPage.HotelId;


Read more:
http://msdn.microsoft.com/en-us/library/ms228169.aspx 



Hope it helps all of you :) 

Wednesday, February 15, 2012

How to remove inline-block extra space above element

I have faced a problem of having an extra space above an element if its display is inline-block in CSS.
I removed the margins and padding but nothing occurs.

To fix this issue, I found that adding 'vertical-align: top;' fixes the problem :)

Hope it helps