Archive | MS Access RSS feed for this section

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.

Follow

Get every new post delivered to your Inbox.