Türkçe   |   English
Calendar
Categories
Archive
Links
Blogroll
Files

22.01.2008
Windows Live Api Poster
As we know Windows Live opened API's to users. There is a poster at the link below which summarizes what could be done with those API's.
http://dev.live.com/img/wlp-mix.pdf
News
Comments(0)

20.01.2008
ExtendedDataTable @ Codeplex

I've enhanced some properties and uploaded the ExtendedDataTable component which I previously wrote an article about. You can view and download it with the source code.
http://www.codeplex.com/ExtendedDataTable

Codes,Open Source
Comments(0)

17.01.2008
Wireless Signal Strength
I was researching how to get wireless signal strength with .Net. I'd like to share the resource i found.
http://www.microsoft.com/technet/scriptcenter/resources/qanda/mar07/hey0322.mspx

And also you can write the WMI Query in .Net as shown below.

ManagementObjectSearcher searcher = null;
searcher = new ManagementObjectSearcher(@"root\WMI", "select Ndis80211ReceivedSignalStrength from MSNdis_80211_ReceivedSignalStrength");
ManagementObjectCollection adapterObjects = searcher.Get();
foreach (ManagementObject mo in adapterObjects)
{
string s = mo["Ndis80211ReceivedSignalStrength"].ToString();
}
Codes
Comments(0)

15.01.2008
Passing Objects Between Pages
In order to pass objects within pages we commonly add objects to session at first page, and we remove objects from session just after reading values at redirected page. It is more manageable to use Context.Item for this purpose since it relases objects automaticly. In order to make this technique redirection should be made by Server.Transfer method.
Clues,Codes
Comments(0)

13.01.2008
Chameleon At Codeplex
As most of you know i develped an application named chameleon which allows users to manage their network settings quickly via setting profiles. From now on i will be publishing my project at Codeplex in order to allow users to track changes and view source code. You can visit the project page at http://www.codeplex.com/chameleoncsm 
News,Open Source
Comments(0)

12.01.2008
location.replace
We commonly set the new page address to window.location.href property to redirect a page at client side via javascript. window.location.replace is a function that provides same functionality however it also loads the new url over current history entry. Redirection with this function does not allow users navigate to the previous URL by using browser's Back button. And finally window.location.relpace('newPage.html') is the syntax of this function.
Clues,Codes
Comments(0)

10.01.2008
Dynamic Top N Query
We use TOP N sql command to show top results of a sql query. However we can't use N as dynamic or parametric in TOP N command like getting value of N from a parameter table or from a parameter of a stored procedure. We can use SET ROWCOUNT command for this purpose. Syntax of this command is SET ROWCOUNT N where n is the count of rows to return where 0 means all rows will be returned. You have to set set rowcount to 0 after executing a command in order not to following queries return top n records.

DECLARE @rowCount int
SET
@rowCount = (SELECT ParameterValue FROM Parameters WHERE ParameterId=12)
SET ROWCOUNT @rowCount
SELECT * FROM MyTable ORDER BY MyColumn
SET ROWCOUNT 0

GO

CREATE PROC MyQuery
@rowCount
int
AS
SET
ROWCOUNT @rowCount
SELECT * FROM MyTable ORDER BY MyColumn
SET ROWCOUNT 0
GO

Clues,Codes
Comments(0)

09.01.2008
ConnectionTimeout / CommandTimeout
Although we establish connection to database successfully sometimes we get timeout error while executing commands in our applications. Increasing the value of ConnectionTimeout property is not a solution for this case. ConnectionTimeout property represents number of seconds to wait for a connection to open. However the CommandTimeout property of Command object represents the maximum wait time in seconds for a command to return value. The default value of CommandTimeout property is 30 and setting this property to value 0 means there is no limit in wait time.
Clues,Codes
Comments(0)

08.01.2008
Math.Round

Math.Round function is commonly used in many applications. However this function may not operate as expected and return expected result in some situations. This is a crutial issue to prevent wrong calculations in our applications.

Math.Round(1.44, 1); //Expected: 1.4 Result 1.4
Math.Round(1.45, 1); //Expected: 1.5 Result 1.4
Math.Round(1.46, 1); //Expected: 1.5 Result 1.5

Math.Round(1.54, 1); //Expected: 1.5 Result 1.5
Math.Round(1.55, 1); //Expected: 1.6 Result 1.6
Math.Round(1.56, 1); //Expected: 1.6 Result 1.6

As seen above when we rounded value of 1,45 to one digit the result was 1,4 instead of 1,5. However same problem was not seen while rounding the value of 1,55 to one digit. The reason of this result is that .Net Framework uses bankers rounding as default rounding system. In bankers rounding system if the value of the digits in d to the right of the decimals position is halfway between the digit in position decimals, that digit is rounded up if it is odd, or left unchanged if it is even. If the precision of d is less than decimals, d is returned unchanged. 

private decimal MyRound(decimal number, int decimals)
{
return decimal.Round(number, decimals, MidpointRounding.AwayFromZero);
}

As a solution of this problem we can use Decimal.Round(Decimal, Int32, MidpointRounding) overload instead of Math.Round function. MidpointRounding enum has AwayFromZero and ToEven options. While ToEven acts as default behaviour in .Net Framework AwayFromZero option acts as we commonly use.

Clues,Codes
Comments(0)

Photos

Microsoft MVP Global Summit 2008
Show All
Entries
News
Articles