Sunday, 29 March 2009

Using keyword

When using anything that implements IDisposable (SqlDateReader, SqlConnection etc) you can use the using keyword to ensure that the object is disposed, e.g.

using (SqlDataReader reader = Dal.ExecuteReader(GetConnection(), "SelectProductAll"))
{
dsScrum.ProductTask.Clear();
if (reader.HasRows)
dsScrum.Product.Load(reader);
}



Is the same as:

SqlDataReader reader = Dal.ExecuteReader(GetConnection(),"SelectProductAll");
try
{
dsScrum.ProductTask.Clear();
if (reader.HasRows)
dsScrum.Product.Load(reader);
}
finally
{
if (reader != null)
reader.Dispose();
}

Wednesday, 25 March 2009

jQuery

I've been looking at using Javascript libraries recently, in order to revamp Lesley's site there are a lot out there (Prototype, Mootools, scriptaculous, Dojo, YUI). I've decided to use JQuery as it appears to have the largest following, which means more support, tutorials and extra plugins. It's also easily extensible meaning you can customise and extend.

What is it? "jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript." In short, you can get Flash-type effects and general all-round sexiness using only javascript, could be used for cool menus, client side table sorting, tabs, AJAX data/image loading, page manipulation, custom dialog boxes, charts etc.

To use you need some understanding of CSS as it uses CSS-style selectors ("li", "#Id", ".class", "a>img" etc) to access elements using jQuery and it appears a lot of the functionality uses CSS to move/position elements.

Here are some good links that I've found:

Tuesday, 24 March 2009

SubSonic

SubSonic..... fed up writing boring DAL code? Me neither.. but if you are this may be for you.

SubSonic has several things we would be interested in but the main selling point is that it auto generates a DAL for you. It also has CMS starter site that seems really cool... more on that later.

I'm not going to re-write their web site help here; so I recommend you visit their site and enjoy the videos. Code is available from codeplex... their site was a little flaky when downloading so I used that instead.

The forums are really good and its been around for a few year now so I think this is something we should all be considering when taking on a new project.

Almost forgot the good news (yes folks it gets better!) its.... wait for it...... OPEN SOURCE!

Enjoy

Tuesday, 17 March 2009

Setup Blackberry demo on standalone PC

I recently had to setup a Blackberry demo onto a standalone laptop, the laptop was a clean install before starting.

I setup everything on the local computer, including Web Service, as it would not be connected to the internet or network.

To setup do the following:

  • Install appropriate .NET Framework.

  • Install IIS and run aspnet_regiis -i.

  • Install jdk-1_5_0_17-windows-i586-p.exe for use by simulator.

  • Install BlackBerry_Email_MDS_4.1.4.exe for MDS simulator to hit network.

  • Install BlackBerry_Simulators_4.5.0.55_8700-Vodafone.exe, or whichever simulator is to be used.

  • Install SQLServer onto laptop. Use either desktop engine and connect via IP Address and enterprise manager from own computer to create database, or install full developer edition with Enterprise Manager.

  • Create new copy of Web Service pointing at (local).

  • Create new copy of Blackberry app, only need to change the connection string in the main _Stub class. Use the laptops computer name as you can't use IP Address as it'll be offline and handset can't hit localhost or 127.0.0.1.

  • Move new .COD into the installation folder of the handset simulator.

  • Go to network connections on laptop and disable all connections (Right Click->Disable). Not sure why but when these are enabled and not connected to network the web service calls are very slow.

  • Run the MDS Simulator first and then open up handset simulator. Done!

I created a batch file to run the MDS and handset simulator:

@echo off
echo Running MDS Simulator...
cd C:\Program Files\Research In Motion\Blackberry Email and MDS Services Simulators 4.1.4\MDS
call run.bat
echo Running 8700 Simulator...
cd C:\Program Files\Research In Motion\Blackberry Smartphone Simulators 4.5.0\4.5.0.55 (8700-Vodafone)
call 8700-Vodafone.bat
pause

Wednesday, 11 February 2009

Change simulator used in Eclipse

To change the simulator the cod file is loaded into when you debug in eclipse (you’ll need the VS plugin installed first as you get more handsets with this):

  • Right click on the project name and select Debug As… -> Debug Configuration

  • Select the Simulator tab on the right.

  • Click New, and enter a name.

  • Click the advanced tab and change the Working Directory to: C:\Program Files\Research In Motion\BlackBerry VS8 Plugin\handheld\simulator

  • Now go back to the General tab and you should be able to select which one you want from the Device drop down. e.g. 8700-black.

  • If the Device drop down has nothing in it enter the following into the Command Line of the Advanced tab: C:\Program Files\Research In Motion\BlackBerry VS8 Plugin\handheld\simulator\fledge.exe /app=Jvm.dll /session=8700-black /app-param=DisableRegistration /app-param=JvmAlxConfigFile:8700-black.xml /data-port=0x4d44 /data-port=0x4d4e /pin=0x2100000A /handheld=8700-black

Sunday, 18 January 2009

webdev.webserver error

I got the above error in VS.NET 2008 when running an ASP.NET app. When trying to debug or show in browser the IDE gives the error in the standard "report to microsoft" dialog box followed by the following message "unable to connect to the asp.net development server".

To fix this error:
  • Right click on the project in solution explorer.

  • Hit F4 for properties (don't right click for properties).

  • Change "Use Dynamic Ports" to false and enter a new port number. Use one quite close to the current port number, I used 1080. Default was 1071.

Thursday, 15 January 2009

Show Modal form from Background Application

To show a message from within a background application we can’t just use Dialog.alert(); because this will throw errors as the application is not using the Ui thread. Use the following code to launch a message/screen from the app:

Application.getApplication().invokeAndWait(new Runnable()
{
public void run()
{
UiEngine ui = Ui.getUiEngine();
Screen screen = new Dialog("Message", new Object[]{"Ok","Cancel"}, null, 0, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION));
ui.pushGlobalScreen(screen, 1, UiEngine.GLOBAL_MODAL);

String
modalResult = ((Dialog)screen).getSelectedValue();
}
});

Can change the screen constructor depending on screen required, the above example just gives an Ok and Cancel button. Use the invokeAndWait() method blocks the current thread and waits for user to click button to give reply.
Free Hit Counter