Tuesday, November 30, 2010

Sql Server–Execute Permissions

One way to provide users execute permissions on a database: (works in Sql Server 2005 and above)
Create a role and grant it execute permissions. Then add your user to that role.
/* CREATE A NEW ROLE */
CREATE ROLE db_executor

/* GRANT EXECUTE TO THE ROLE */
GRANT EXECUTE TO db_executor

Monday, November 29, 2010

Samsung Focus–Diagnostics commands

via: http://forum.xda-developers.com/wiki/index.php?title=Samsung_Focus

Samsung Focus Diagnostic Mode To access the diagnostic program you will need to dial ##634# from the phone pad.
Diagnostic Commands:

  • *#0*# - LCD Test
  • *#0002*28346# - Audio control utility.
  • *#0011# - Power and Temperature and Network Connection monitoring
  • *#0228# - Battery Information
  • *#0289# - Melody Test\Test External and Internal Speaker
  • *#03# - SMDInfo
  • *#05# - Simple test menu
  • *#06# - Show IMEI #
  • *#0673# - MP3 Test Menu\Shows Audio sound tests
  • *#0782# - Shows Clock & Alarms settings
  • *#0842# - Vibrate test menu
  • *#0987# - Multitouch test
  • *#1111# - Show FTA software version
  • *#1234# - Shows the PDA and the Phone version number
  • *#197328640# - The Root Menu
  • *#2*# - Battery Information
  • *#2222# - Show FTA hardware version
  • *#2263# - RAT Selection option is restricted
  • *#232337# - Bluetooth MAC Address
  • *#2580# - Integrity Control
  • *#3*# - Test Brightness
  • *#32489# - (GSM test) Shows the ciphering status and options to enable or disable it.
  • *#7284# - USB Path control
  • *#745# - Operation (2): Ril log done
  • *#7450# - Operation (99):Error Report off done
  • *#7451# - Operation (99):Error Report off done
  • *#7465625# - Shows status of the Network Service Provider SIM or Corporation lock
  • *#770# - Operation (99):Vphone 770 done!
  • *#771# - Operation (99):Vphone 771 done!
  • *#772# - Operation (99):Vphone 772 done!
  • *#773# - Operation (99):Vphone 773 done!
  • *#774# - Operation (99):Vphone 774 done!
  • *#775# - Operation (99):Vphone 775 done!
  • *#776# - Operation (99):Vphone 776 done!
  • *#777# - Operation (99):Vphone 777 done!
  • *#778# - Operation (99):Vphone 778 done!
  • *#779# - Operation (99):Vphone 779 done!
  • *#780# - Operation (99):SR Test done!
  • *#9090# - Diag Config\UART/USB settings
  • *2767*3855# - Full Reset (Caution every stored data will be deleted.)

Tethering Currently instructions only apply to AT&T network, USA.

  • Open the phone screen composition
  • Enter the code: # # 634 # > Press Call<br.
  • This will open a new screen will be similar but in test mode
  • Then type in the code * # 7284 # > Press Call
  • See the screen that you see in the picture > Select Tethered
  • The phone will restart
  • Attach the USB cable to your phone and PC and wait for it to install drivers
  • You will see the phone modem and you can configure the data connection
  • number: *99***1#
  • user name: WAP@CINGULARGPRS.COM
  • password: CINGULAR1

WP7, Samsung Focus and Tethering

Only available via the diagnostics menu:

Dial ##634#. This will open the diagnostics screen.

Dial *#7284#. This will open the tethering configuration dialog.

Select the option “Modem, tethered call”. The phone will take you through a set of steps to configure tethering and will restart the phone. Voila! tethering is now enabled.

Danger: You run the risk of bricking your phone, getting crazy bills from your carrier, etc. So do the above at your own risk.

Sunday, November 28, 2010

Fear and Risk

If you arent scared then you arent taking a risk

for a nation to remain true to its ideals….

For if this Nation is to remain true to the ideals symbolized by its flag, it must not wield the tools of tyrants even to resist an assault by the forces of tyranny.

Justice John Paul Stevens.

Saturday, November 27, 2010

Determining theme on WP7

Knowing which theme has been selected by the user for their WP7 device is important especially if you are using images or colors that work well for one theme and not another. In this case you will have to change the colors/images depending on the currently selected theme.

Here is the simplest way to determine whether the currently selected theme is “Light” or “Dark”

public static bool LightThemeEnabled
{
get
{
return (Visibility)Application.Current.Resources["PhoneLightThemeVisibility"] == Visibility.Visible;
}
}

The property returns true if the currently selected theme is the light theme and false if the selected theme is the dark theme.

Incidentally, this is one of the easiest reasons for your app to get rejected during certification for the Market Place. So remember to check all your screens under both the Light and Dark themes.

Jailbreaking comes to WP7

Its called ChevronWp7 and you can read more about it at: http://www.istartedsomething.com/20101126/chevronwp7-windows-phone-7-unlocker-released/

Friday, November 26, 2010

WP7 – Screen Capture on Device

One of the biggest features that I miss as a developer/blogger on the Windows Phone 7 device is the ability to take a screen shot.

The saving grace is that it is extremely easy to add code to your app so as to be able to capture the screen and save it to your album. Once the image has been saved, you can upload it to SkyDrive or to your computer via a Sync operation. (This is better than storing it to isolated storage, as that makes it harder to get at the image).

Here is the code:

using System.Windows.Media.Imaging;
using Microsoft.Advertising.Mobile.UI;
using Microsoft.Phone.Controls;
using Microsoft.Xna.Framework.Media;
using System.IO;

public static class Utility
{
/// <summary>
/// Currently supported only on the device. (Does not do anything while running with the emulator)
/// Will throw an exception if called while the device is connected to the computer (tethered mode)
/// so dont do that!
/// </summary>
/// <param name="page">the page whose screen shot needs to be captured</param>
/// <param name="saveName">the name that the image should be saved under - the device seems to ignore this parameter
/// and hence its ok to call this method with the same name multiple times, each image is stored separately</param>
/// <param name="quality">the jpeg image quality parameter</param>
/// <returns>A picture object representing the image</returns>
public static Picture DoCapture(this PhoneApplicationPage page, string saveName, int quality)
{
//first save to bitmap
WriteableBitmap bmp = new WriteableBitmap((int)page.ActualWidth, (int)page.ActualHeight);
bmp.Render(page, null);
bmp.Invalidate();

//get memoryStream from bitmap and save to media library
Picture picture = null;
using (MemoryStream memoryStream = new MemoryStream())
{
bmp.SaveJpeg(memoryStream, bmp.PixelWidth, bmp.PixelHeight, 0, quality);
MediaLibrary mediaTest = new MediaLibrary();

memoryStream.Seek(0, SeekOrigin.Begin);
//name cannot be empty or null
//by default image gets saved to the album "Saved Pictures"
//SavePicture will throw an exception if called while the device is tethered
picture = mediaTest.SavePicture(saveName, memoryStream);
}
return picture;
}
}

And here is one method to call it from one of your application’s pages:

private void ApplicationBarCaptureButton_Click(object sender, EventArgs e)
{
try
{
Picture picture = this.DoCapture("Stocks 50-200.jpg",95);
MessageBox.Show("Screen capture saved: " + picture.Album + " " + picture.Name, "Screen Captured",
MessageBoxButton.OK);
}
catch (Exception exp)
{
MessageBox.Show(exp.Message, "Error saving screen", MessageBoxButton.OK);
throw;
}
}

Something to notice is that as DoCapture was defined as an extension method, I am able to call it using the following syntax: this.DoCapture.

And here is what a saved screen-shot looks like (taken from my WP7 App – Stocks 50-200):

69

Thursday, November 25, 2010

Sunday, November 21, 2010

Cool Windows Phone 7 Features via Windows Live

No paying a $100 for a “MobileMe” service. The following awesome features come standard with your Windows Phone 7.

The images say everything:

Map it: see your phone’s approximate location

image

Ring it: Ring your phone, even if its on silent or vibrate mode!

image

Lock it: Lock your phone and even put a “please return” note on it.

image

Erase it: Erase all your personal information remotely.

image

Do more at WindowsPhone.Live.Com