Like many Android device owners I have recently upgraded my Samsung Galaxy SII to Ice Cream Sandwich (Android v4.0.x). All great and lovely – Still finding/exploring the new features and getting used to the slightly new ways of working in some areas.

I do however have a gripe…and being a driver and music lover, its actually quite a major gripe: Since upgrading I ca no longer control my phone via my car headset. Sure it connects (although this seems much less reliable since the upgrade) and will play, but I have to control it via the the phone, which is actually a big No whilst driving – The Samsung SII is a touch screen only device, all bar the home button/volume/power (like many phones now), so to change tracks for example, I need to look at my phone, instead of the tactile buttons on my car headset which I can ‘touch type’ on, as I can with the steering column control unit.

So – Why is it no longer working? From what I’ve been reading, it seems Google updated the implementation of AVRCP (Audio Video Remote Control Protocol) with Ice Cream Sandwich meaning that software calling the API for functions such as skip track no longer send the expected command. It seems also that this has effected the majority of music sofware for Android, apart from a few, including Google Music.

So – The likes of WinAmp (My choice of music player for Android) will need to update their software to work with the new bluetooth stack. If I could find Google Music on Google Play (Google Play = App Store) I would install and use it – At least until WinAmp is updated (Updated that is, not fixed…as its not WinAmp thats broken!). I’m about to try the Music player that comes with the Galaxy SII…Hopefully that will see me through.

Google are aware of the issue…Lets hope a fix appears soon.

XBOX + DD-WRT + DHCP = FAIL

January 29, 2011

Following months of sporadic failures, endless reboots and reconfiguring (With no real time put into solving the issues) I’ve dropped Hyper-WRT for DD-WRT. This seems to have been a good move (Although please see the warning below!) – My connection is much more reliable, feels more responsive (un-proven as yet) and I’m enjoying the extra features that DD-WRT offers (e.g. My router is now over-clocked – Waiting for the burn out in a few days???).

One issue that arose was when I first went to use my XBOX to stream a movie from my PC – Network failure, which when I ran the XBOX network diags I found was a DHCP failure.

Solution – The out-of-the-box configuration for DD-WRT sets a DHCP lease time of 0 – Which XBOX no likey! Since increasing this to 240 minutes, all seems well and good!

One word of warning with DD-WRT – I don’t know if this is a problem with my upgrade/router, but having checked through all the settings following the upgrade, I noticed the WiFi was configured as before, but with security OFF. This is a big problem if you don’t notice it! Months with an open WiFi door will at some point mean hassle!

I recently had a requirement to query some data in another DataBase, which of course was not available within the main DataContext for my application. At first, I thought I would add a seperate DataContext for the related data, then query it to get the related records, generate data tables and perform a join – This all seemed rather inefficient.

After some trial and error I discovered it is possible to connect to different databases from within one single Linq2SQL data context.

Heres how I did it:
(Below assumes you already have a working Linq2SQL DataContext in place)

  1. In server explorer, add a connection to the database you want the data from (B)
  2. Open your existing DataContext (.DBML File), which will have table(s) from a different database (A)
  3. Drag the required table(s) from (B) to the DataContext
  4. For each table you use, view the properties and change the source to qualify the database name, e.g. dbo.Countries becomes DatabaseB.dbo.Countries
  5. The DataContext will only connect using one connection, so you’ll need to connect to SQL with an account that has the relevent permissions for each database

Whats the Point in this?

After doing the above, I was able to query two databases at once using a cross-database join. This in itself it nothing new – Its been possible in SQL server at least since SQL 2000, but achieving the same result in LINQ2SQL was not obvious. Its also very handy to be able to connect to another database when required – But I really would recommend considering two DataContexts for this – Although bear in mind points below…

Useful Pointers:

  • It is possible to specify the connection string when instantiating the connection – This will work fine if you only want data from one place at a time, although if this is the case you may as well have two DataConext
  • Joins will not work across DataContexts
  • I actually ended up using the same account that was used to connect to Database A, simply giving this read permission to Database B – But be very careful here!
  • It’s a good idea to rename the related classes in your DataContext so you (and future developers) know that these are from a separate database. I suggest prefixing them with the database name, followed by an underscore

Being that you are reading my blog, there is a fair chance that you have some connection to the IT industry, or perhaps you are just into computers, software development and other such geeky stuff? If this is true, you will no doubt of heard of ‘open source’ software, probably numerous times in fact.

My question is – Have you seriously considered open-source/free software as an option? You don’t have to switch your O/S to Linux to take advantage of free, well supported, well documented software you know! Below is my list of open-source/free software must-haves. Enjoy.

I’m making heavy use of Linq2SQL right now, which for the main is working very well. I create my stored procedures, drag them onto the Linq2SQL surface designer, then use them in my code – All makes good sense and keeps the logic in sensible places. One problem I have noticed is that you cannot use a stored procedure with Linq2SQL that uses dynamic SQL.

Example:

Stored Procedure:

(I know, theres no reason for this to use dynamic SQL, its purely to demonstrate the issue!)

CREATE PROCEDURE [dbo].[GetSomeData]
	@myVar varchar(5)
AS
	BEGIN
	DECLARE @CMD VARCHAR(2000)
	SET NOCOUNT ON;
	SET @CMD = 'SELECT SomeTable.SomeColumn FROM SomeTable
		  'WHERE (SomeTable.SomeColumn = ''' + @myVar + ''');'
	EXEC(@CMD)
END

C# Code to loop data returned from stored procedure:

foreach (var foo in DB.GetSomeData(someVar))
{
	// Do Something...
}

Runtime error on the foreach loop:

	foreach statement cannot operate on variables of type 'int' because
	'int' does not contain a public definition for 'GetEnumerator'

The Fix?

Create your stored procedure with the same signiture and name, but with any static SQL (Ideally returning the same columns). Drag it onto the Linq2SQL surface designer, compile and then amend your storedprocedure to suit (e.g. Add our dynamic SQL). This means the resultant LINQ method will have a data type of ‘auto-generated’ rather then unknown, which means your loop will work as expected. Its far from ideal, but it works and its the only solution I’ve found as yet. If you know of an easier solution, leave me a comment! I’m hoping this will be fixed in Visual Studio 2008 SP1.

I just found this CodeGuru post in which ‘Mendhak’ profiles the top level new features coming with Visual Studio 2010 and the .Net framework v4.0. Us developers really do have a lot to look forward to! Some of the more notable enhancments, for me are:

If you are a developer I would recommend you take 15 minutes of your time to have a read!

Read the post here

On Monday this week (17/03/2008) Microsoft released Windows Vista Service Pack 1 on its public download site. The update has been available to MSDN subscribers for a while now, and will be pushed out as a Windows update package next month.

Download Windows Vista Service Pack 1
(All 434.5mb of it!)

Virgin Media Upgrades

February 15, 2008

Virgin media today announced roll out of a 10mb (Large Broadband) upgrade for all current 4mb (Medium Broadband) customers at no additional cost.

Details of roll out locations and dates

On more than one occasion I have found myself working on a server trying to install an application only to find the system drive is very low on space.

Although it wont solve this problem for you a free application called JDiskReport available from http://www.jgoodies.com/ will certainly help you find out exactly whats using all that space.

It works by scanning a given drive/folder which is then presented as a pie-chart that you can use to drill-down into the various folders, showing you a new pie-chart for each level.

I used it today and within 4-5 minutes had found nearly 8gb of unrequired log files on a server. Of course, the real solution is to not disk space become a problem in the first place, with a little bit of planning and consideration to the fact that disk space is far from expensive these days!

I’ve just built a .Net page to display some data in a datagrid, with alternating row colours. When I have done this in the past, I have always ended up defining the CSS classes as follows:

.DataRow {
font-family:Verdana;
font-size:10.5pt;
background-color:#CCCCCC;
}

.DataRowAlternating {
font-family:Verdana;
font-size:10.5pt;
background-color:#FFFFFF;
}

Note how each of the classes has the same values for the properties, apart from the color (In reality you would probably have more properties defined). This obviously doesnt lend itself to easy updates or code maintenance.

The answer, as I just discovered is CSS Grouping. The example below will achieve exactly what the above example does – Only with less code duplication.


.DataRow,.DataRowAlternating
{
/* Properties common to both classes... */
font-family:Verdana;
font-size:10.5pt;
}

.DataRow
{
/* Properties specific to .DataRow... */
background-color: #CCCCCC;
}

.DataRowAlternating
{
/* Properties specific to .DataRowAlternating... */
background-color:#FFFFFF;
}

This is about as close to inheritance in CSS as we can get for now, and if you ask me – Its good enough!

Follow

Get every new post delivered to your Inbox.

Join 30 other followers