VB Express 2008, x64 and Database woes

Just a quick post to hopefully save some poor soul the same pains I’ve gone through while looking into some problems with Visual Studio Express and database connectivity.

Woe No. 1

Having tried to connect to a SQL database (SQL Express) and finding various articles on the Internet about issues on 64-bit versions of Windows Vista and Windows 7, it seems that VS2008 Express (VB and C#) does not have the capability to connect to a SQL database (you can connect to a local MDF file apparently, but not to your SQL Server). So don’t go through uninstalling SQL Express and install the 32-bit version, then uninstall again and install the 64-bit version, then try various combinations of SQL connectivity configuration (TCP/IP, Named Pipes etc.). It won’t work!

You can connect to SQL databases if you’re using Visual Web Express though (not that I wanted to yet!).

Woe No. 2

So, I tried connecting to an Access database instead – and put the old Northwind database somewhere accessible. After sorting out my data connection in Database Explorer (it’s called Server Explorer in non-Express versions), I previewed my data and the preview showed up all the rows in the relevant table – great start 🙂

But…(you knew there was a but!)…when I ran my program the table didn’t return any rows at all, just an empty data grid.

After hunting around on the Internet again, it seems that there is a connectivity issue because the Access drivers are 32-bit, but the default for compilation on a 64-bit system (you guessed it) is 64-bit. So naturally you just change the compilation to 64-bit in your Visual Studio project by going into the Project Properties and setting the Platform to 64-bit. That’s okay if you have the full Visual Studio, but it doesn’t work for VS Express.

To be able to see the option in VS Express you need to go to Tools, Options, Project Solutions and check “Show advanced build configurations”. This will expose the necessary drop-down, but you won’t be able to select 64-bit – arghh! You then need to go to Build, Configuration Manager and in the Platform drop-down box for your project select “New” and select x86 from the options.

An alternative “fix” is to close your VB Project, go to the project folder and edit the vbproj.user file in your favourite text editor (Notepad++ is my editor of choice), and add <PlatformTarget>x86</PlatformTarget> before the closing </PropertyGroup> tag.

Finally, we come to:

Woe No. 3

Basically, I seemed to lose my project’s Form completely at one point (during form design, before I’d put any code behind it), not sure how I did it, but here’s what happens:

You open your Project, and you have your form under Solution Explorer (e.g Form1.vb), but you can only see a code window for it and there are no Designer options!

This happens because there is no code at all (maybe you made a mistake and deleted it) – but because there isn’t a Class definition for the form, you lose the option for the Designer (sounds like a bug to me). Anyway, to fix it add these lines to your Form1.vb code (or whatever your form is called) and you will get the “View Designer” option back:

Public Class Form1

End Class

As the Meerkat says, “Simples!”.

So there you go, if you must do things on the cheap (or you’re just starting out with .NET programming and using the Express Editions), you may find some teething pains. However, like me, you might find the experience teaches you a few things as well. And remember…Google is your friend 🙂

Comments are closed