OLE DB (MS Access) database connection problem in 64bit operating with C#

19 May

From last couple of weeks I am developing a desktop software called “TSF Core” built with C#. This software is replacement of a web (Apache, MySQL) admin panel based one web service (WSDL). I am using MS Access as a cash database to make the more process faster.

I was getting an exception with my database connection in 64bit vista ultimate bit it was working fine in XP 32bit, 2000 and VISTA 32 bit OS.

I am using Microsoft.Jet.OLEDB.4.0; to connect with .mdb. Connection string is something like that:

new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=tsf_barcode_reader.mdb");

I got a strange result when I Googled on it. There is no OLEDB version for 64Bit Operating system.

But there is a good solution for that at least it worked for my software. We can specify the software platform in project definition. To do this please open "my_project.csproj" in notepad or any other plain text editor and add the following code under "PropertyGroup" tag.

<PlatformTarget>x86</PlatformTarget>

Code will be some ting like that:

Previouse code:

<PropertyGroup Condition=" ‘$(Configuration)|$(Platform)’ == ‘Debug|AnyCPU’ ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" ‘$(Configuration)|$(Platform)’ == ‘Release|AnyCPU’ ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>

Edited Cdoe

<PropertyGroup Condition=" ‘$(Configuration)|$(Platform)’ == ‘Debug|AnyCPU’ ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" ‘$(Configuration)|$(Platform)’ == ‘Release|AnyCPU’ ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>

In this situation the operations system will call 32 bit compatible database connection provider for that software and the problem will be solved.

Advertisements

5 Responses to “OLE DB (MS Access) database connection problem in 64bit operating with C#”

  1. Rumana June 11, 2009 at 8:46 am #

    This is helpful, thnx Reza vi,

  2. Rubel June 11, 2009 at 9:17 am #

    🙂

  3. Todd August 3, 2009 at 7:01 pm #

    By doing this, your software will only run in 32-bit. Under a 64-bit Windows OS, the software will run in WOW64 (i.e. emulated 32-bit mode).

  4. Rubel August 4, 2009 at 2:39 am #

    😉
    WOW, Is the best way to try any 32 bit software in 64bit OS. Specially Vista.

  5. dan August 27, 2012 at 7:18 pm #

    hello there and thanks for your information ? I have certainly picked up anything new from proper here. I did then again experience a few technical issues the use of this web site, since I experienced to reload the web site lots of times prior to I may get it to load correctly. I had been thinking about if your hosting is OK? No longer that I am complaining, however sluggish loading cases occasions will sometimes affect your placement in google and could injury your high-quality rating if advertising and marketing with Adwords. Well I am adding this RSS to my e-mail and could glance out for much extra of your respective exciting content. Make sure you replace this once more very soon..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: