Posts tagged tutorial

BingMapsDirectionsTask – Getting driving / walking directions

2

I was revisiting my old projects and reflecting on how I could improve on those products. I didn’t realised that there are so much we can do with the new Windows Phone APIs! I was looking at the MSDN’s Microsoft.Phone.Tasks Namespace and found out that there is a Bing Maps Direction Task Class now!

The first thing I thought of was the Green App project which I did during codeXtremeApps 2010 Its a Windows Phone 7 project where we direct our users to the nearest recyling bin around Singapore for them to recyle their waste product. There are more functions which I will not elaborate on here. I will be updating my project/portfolio page soon! I was playing with the Bing Maps Direction Task API just this afternoon. Thought it will be useful to post a tutorial on how to use it. :) Should you face with any problems, feel free to contact me via the Contact Me form or email me at guohong@limguohong.com

Step 1 : Adding using Microsoft.Phone.Tasks and using System.Device.Location into references.

Bing Maps Directions Task 1 - Adding Reference

Bing Maps Directions Task 2 - Adding namespace

Step 2 :  Adding the Microsoft.Phone.Tasks and System.Device.Location into the project

Bing Maps Directions Task 3 - Adding namespace

Step 3 : Initialize a BingMapsDirectionsTask and create a start and end LabeledMapLocation . Note that start is optional. Should you not provide start location, the API will use the current location by default.

At the end of it, .Show() it and it will show the map.

BingMapsDirectionsTask Direction = new BingMapsDirectionsTask();

LabeledMapLocation start = new LabeledMapLocation(“Hougang Ave 4 919 Singapore , Singapore”, null);
LabeledMapLocation end = new LabeledMapLocation(“Paya Lebar Air Base, Singapore”, null);

Direction.Start = start;
Direction.End = end;

Direction.Show();

You can download a usage demostration of the class here. Source code included.

Please note that this is written for WP7.1

Bing Map Direction Task Demo Source Code Screenshot

Bing Map Direction Task Demo Source Code Screenshot

P.S: These 2 classes caught my attention, when I have some spare time, I will look into if I will be able to use it in my Slime Sweeper 2! ShareLinkTask class and Share Status Task Class!

If you have any questions, feel free to contact me via the contact form, comment or email me at guohong@limguohong.com

Do check out the tutorial page too!

Microsoft Excel 2010 – Protecting selected cells

3

I was at Yishun Town Secondary School the other day to assist on the Gerald, Microsoft School Technology Innovation Center Manager, presentation on a hands on session for Microsoft Office techology.

We were posed some questions, I realised that it is useful to post some of them in a form of guide here so it will help teachers. How do we protect some cells and not allow editing on them while allowing some others to be edited. It will be useful when ICT HODs or teachers want to do up an excel document with the formulas and wish to send to his/her team to use but they do not want them to mess it up.


1. First, lets open up Microsoft Excel 2010.


2. In this example, we will add first and second column and show the result in the third column.
Select A3, go to Formulas tab > AutoSum > Sum


3. Select A1 and A2 for your data range.


4. On the bottom right of the cell, you will see a enlarged black dot, click on it and drag it all the way down to 20th row. ( In this example, we will just make use of 20 rows for the calculation. )


5. You will see something like this.


6. Right click on the 20 cells and go to Format Cells


7. Go to Protection and make sure Locked is ticked. This means these cells are not allowed to be edited.


8. Now Select A1 to B20


9. Right click on the selected cells and go to Format Cells


10. Go to the Protection Tab and untick Locked ( This means these cells can be edited )


11. You might want to color the cells so that your end user will know that these cells can be edited by going to Home tab > Cell Styles > choose Input.


12. Go to Review tab > Protect Sheet


13. Input a password into the dialog box which appears. Please remember the password as you require that to unlock.


14. Another dialog box will appear to confirm the password, input the same password in again.


15. Try inputing values in A1-B20 and you will realised that you can do it but you cant do it when you try on other cells.

This concludes the tutorial on how do you protect selected cells in Microsoft Excel 2010. I have attached the sample document which you can download and have a look.

http://cid-29f099c37b76ca59.office.live.com/self.aspx/Blog/Office%20Demo/Protecting%5E_Selected%5E_Cells.xlsx

Should you have any question, please feel free to contact me at guohong@limguohong.com

Connecting to SQL Azure with PHP

2

To start, I would like to first say that although many PHP developers usually recommend MySQL as the accompanying database for PHP, it is not difficult to interface PHP with other databases such as SQL Azure, Microsoft’s cloud-based relational database offering.

PHP connects with SQL Azure in a similar manner as how it does with Microsoft SQL Server, ie through an interface known as the Open Database Connectivity (ODBC), which is actually the standard software interface for accessing databases. Each platform and database has its own implementation following the ODBC standard but for this tutorial, I’ll focus on PHP.

There are a few ways to connect your php site to MS SQL but the 2 main approaches are as shown in Figure 1.0.

1. Using the “php_mssql.dll” php extension requiring MS SQL Client Tools installed (Figure 1.0, right column).
2. Using the “sqlsrv” driver (“Microsoft Drivers for PHP for SQL Server”) requiring MS SQL Native Client installed (Figure 1.0, left column)


Figure 1.0

I will be using the 2nd approach for this tutorial because it supports both PHP 5.2 and 5.3, unlike the 1st which is not available for PHP 5.3.

Microsoft Drivers for PHP for SQL Server
As of 1 February 2011, the latest version of the driver is version 2.0.1 (30 November 2010).
You can grab it from http://www.microsoft.com/downloads/en/details.aspx?FamilyID=80e44913-24b4-4113-8807-caae6cf2ca05
Once you have installed the drivers, you should see the following in the installation directory:


Figure 2.0

We will be using the “php_sqlsrv_53_nts_vc9.dll” library for this tutorial.
• “php_sqlsrv” –> Driver name
• “53” –> PHP 5.3
• “nts” –> Non-thread safe (The PHP FastCGI Handler of IIS handles thread-safe operations for PHP, use the non-thread safe version to reduce performance issues)
• “vc9” –> Library compiled using VS 2008, use vc6 (VS 6) if PHP is running on Apache
Configure PHP
1. Copy “php_sqlsrv_53_nts_vc9.dll” into the “ext” folder of your php installation directory.
2. Edit the php.ini to include the library


Figure 3.0


Microsoft SQL Server 2008 R2 Native Client
In order for the PHP for SQL Server Drivers to work, the necessary SQL Server ODBC drivers must be installed on the web server.
The version of the ODBC driver needed for SQL Azure comes with the SQL Server 2008 R2 Native Client.
You can grab it from http://www.microsoft.com/downloads/en/details.aspx?FamilyID=ceb4346f-657f-4d28-83f5-aae0c5c83d52

PHP Syntax
After all the preparation and configuration, here comes the actual thing -> Coding!
This tutorial showcases how to do simple CRUD (Create, Retrieve, Update, Delete) commands.
1. Connect to Database:

$serverName = “servername.database.windows.net”;
$connInfo = array(“UID”=>”username@servername”,
“PWD”=>”password”,
“Database”=>”databasename”);
$conn = sqlsrv_connect($serverName, $connInfo);

2. Insert data to Database (taking data from a html form text field):

$comment = $_POST["txtComment"];
$comm = “INSERT INTO commentsqlazure (commentContent) VALUES (?)”;
$stmt = sqlsrv_prepare($conn, $comm, array(&$comment));
$result = sqlsrv_execute($stmt);

3. Update data in Database:

$Id = $_POST["txtUpdateId"];
$comment = $_POST["txtUpdateComment"];
$comm = “UPDATE commentsqlazure SET commentContent = ? WHERE id = ?”;
$stmt = sqlsrv_prepare($conn, $comm, array(&$comment, &$Id));
$result = sqlsrv_execute($stmt);

4. Remove data from Database:

$Id = $_POST["txtRemoveId"];
$comm = “DELETE FROM commentsqlazure WHERE id = ?”;
$stmt = sqlsrv_prepare($conn, $comm, array(&$Id));
$result = sqlsrv_execute($stmt);

5. Retrieve data from Database:

$comm = “SELECT id, commentContent FROM commentsqlazure”;
$stmt = sqlsrv_query($conn, $comm);
while($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC))
{
echo $row["id"].” “.$row["commentContent"].”
“;
}

6. Close connection and release resources:

sqlsrv_free_stmt($stmt);
sqlsrv_close($conn);

You can download the project file from here.
http://cid-29f099c37b76ca59.office.live.com/browse.aspx/Blog/Code%20Guide/SQL%20Azure?uc=1

Please take note that you have to change the Server Name, Username, Password at the connection string to make this work. You should run the following script to the table first.
http://cid-29f099c37b76ca59.office.live.com/self.aspx/Blog/Code%20Guide/SQL%20Azure/SQLAzureConnection.sql

Credit to Luke Ng.

Creating your first game on Popfly

0

Microsoft Popfly (internally codenamed Springfield) is a website that allows users to create web pages, program snippets, and mashups using the Microsoft Silverlight rich internet applications runtime and the set of online tools provided. Popfly is currently in Beta stage of development. It requires users to log in with their Windows Live ID, and provide additional information about themselves when logging in for the first time to use Popfly.

Quoted from http://en.wikipedia.org/wiki/Microsoft_Popfly

http://www.popfly.com | I will be giving a tutorial on how to create a game on popfly. I personally think making a game on popfly all boils down to 3 simple general steps.

1. Ideas
2. Creating the game
3. Tweak the game to make it better

I will be teaching mainly the second stage, the creation of the game. I will pull in some simple functions which most people will be using when they are creating a game on popfly. Without further ado, we will start the fun!

(more…)

What I will be doing next?

0

Seems like its about 90% done.

I am looking to do a full HTML or CSS reference and tutorial website once I am done with my current website and promotion.

I have a few domains to use.

To do list:
-Upgrade my blog’s script
-C# boot camp #2 / #3 ( Its lying in my admin panel for very long already. )
-Disclaimer and About Me page.
-Clear up unused domains in my cPanel
-Clear up unused MySQL in my cPanel

Go to Top