Hot File

A few tips on how to connect and work with an Access database in MS Visual Studio

View: 757    Dowload: 0   Comment: 0   Post by: hanhga  
Author: jrkOptimus   Category: MS Office   Fields: none

7 point/5 review File has been tested

Some days ago I had to make software to a client who asked for a local MS Access database as a must. Then I spent a few days researching on the subject, but no matter what, I couldn’t get the database to connect. After a few head bangs I managed to successfully connect the database to my project discovering the whole topic was a lot much easier than you may think. Here I give you a list of the problems I had to address and how I solved them.

Introduction

I just wanted and option that allowed me to save data and not overwritten but also with the option to reflect changes I made to the project database. Then I had to make a little hack, and this hack was the motivation for me to make this small article.

The trick is in development time, connect to the project database not a database located in an output folder. For that hack you have to modify the connection string like this:

  • The first problem was about the connection, after reading a few forums about connection strings, ODBC access, OLE access, making connection files, all of that was useless for me. Then I discovered that I could drag the database to my project and… voila! It was successfully configured.
  • Another problem I had is that I couldn’t make any query because it said that the MS.jet driver was not installed on this PC. Later after reading some forums, I found out that I had to switch my platform target on the project build options from “Any CPU” to “X86” that was because Microsoft hasn’t implemented OLEDB 64 bit drivers yet.
  • Having the possibility to perform queries on the database, I couldn’t make the data to be persistent, that means anytime I compiled the software the database data was lost. That problem is because any time you compile the database on the executable folder was overwritten by the project database that was in the project root folder and that was the database Visual Studio opened to configure. After checking the possible configurations, I discovered that all were wrong for my project, for example:
    1. Copy always: was the default option and overwrites the saved data
    2. Do not copy: it didn’t overwrite saved data but changes on datatables and database weren’t reflected on the local database
    3. Copy if newer: that option also overwrote my data, just anytime I saved data to the database.
static public void Configure()
{
    string connectionString = 
       "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\..\database.mdb;Persist Security Info=True";
    uta.Connection.ConnectionString = connectionString;
    tdta.Connection.ConnectionString = connectionString;
    pta.Connection.ConnectionString = connectionString;
    abta.Connection.ConnectionString = connectionString;
    sta.Connection.ConnectionString = connectionString;
    saleTa.Connection.ConnectionString = connectionString;
    spta.Connection.ConnectionString = connectionString;
    pota.Connection.ConnectionString = connectionString;
    tabPta.Connection.ConnectionString = connectionString;
}

Type this in Notepad and save it as a .bat file. Use this file in the above mentioned steps.

 

A few tips on how to connect and work with an Access database in MS Visual Studio

A few tips on how to connect and work with an Access database in MS Visual Studio Posted on 22-03-2014  Some days ago I had to make software to a client who asked for a local MS Access database as a must. Then I spent a few days researching on the subject, but no matter what, I couldn’t get the database to connect. After a few head bangs I managed to successfully connect the database to my project discovering the whole topic was a lot much easier than you may think. Here I give you a list of the problems I had to address and how I solved them. 1.4/10 757

Comment:

To comment you must be logged in members.

Files with category

  • Document Library - Enable New Document, Edit Document Features

    View: 1872    Download: 0   Comment: 0   Author: none  

    Document Library - Enable New Document, Edit Document Features

    Category: MS Office
    Fields: Other

    0/5 review
    In this article we can explore the underlying aspects involved in enabling the New Document feature in a Document Library.

  • Generating Excel (XML Spreadsheet) in C#

    View: 2426    Download: 2   Comment: 0   Author: none  

    Generating Excel (XML Spreadsheet) in C#

    Category: MS Office
    Fields: Other

    0.5625/8 review
    Recently, I was working on a web based report in ASP.NET. The report had to be generated in MS Excel format and the data was too much. To give you an idea, I had to generate more than 300 worksheets and the file size was more than 5 MB. I tried the...

  • Searching - Human Way and Index Way

    View: 1942    Download: 0   Comment: 0   Author: none  

    Searching - Human Way and Index Way

    Category: MS Office
    Fields: Other

    0.093023255813953/86 review
    It was really an art to optimize the data retrieval from database and data retrieval optimization is part of every developer's life. Indexes are one of the best ways of Optimization that SQL Servers provide. Understanding indexes some time may be...

  • Creating Pivot Tables and Charts Using ActiveX

    View: 2507    Download: 0   Comment: 0   Author: none  

    Creating Pivot Tables and Charts Using ActiveX

    Category: MS Office
    Fields: none

    1.125/4 review
    Most of us (developers) use the “Generate Excel” feature in our applications. This allows us to generate an Excel copy on any of our reports. Most of us are also familiar with “Pivot Table” and “Pivot Charts”. This feature from MS Excel allows the...

  • Automating MS Excel Documents

    View: 1847    Download: 0   Comment: 0   Author: none  

    Automating MS Excel Documents

    Category: MS Office
    Fields: Other

    0/3 review
    I have been working on automating MS Office applications since some time. I have seen that it is very easy to find information on automation of MS Word but it is difficult to find information on automation of PowerPoint or Excel. So I decided to...

  • Embedding PowerPoint presentation player into a WPF application

    View: 952    Download: 0   Comment: 0   Author: none  

    Embedding PowerPoint presentation player into a WPF application

    Category: MS Office
    Fields: Other

    0/2 review
    On one occasion I came across an interesting and, I can even say, challenging task of building a customized player of PowerPoint presentations. This task emerged as part of a project which my teammates and I developed at Reliable Systems. Our...

  • Parallel Processing MS Access VBA Application

    View: 921    Download: 0   Comment: 0   Author: none  

    Parallel Processing MS Access VBA Application

    Category: MS Office
    Fields: Other

    0/1 review
    I got a challenging assignment to provide alarm capability on top of an existing application, written in VBA Access. This required a few issues to be dealt with and resolved. I will, in this article, describe the steps I took to provide parallel...

  • Microsoft Office XML formats, defective by design?

    View: 3477    Download: 0   Comment: 0   Author: none  

    Microsoft Office XML formats, defective by design?

    Category: MS Office
    Fields: Other

    0/549 review
    Microsoft is trying to push new file formats that are using Zip and XML. Are those new file formats any good for Office developers? In other words, should anyone feel safe to make direct access to file parts, and start getting free of running...

 
Newsletter Email

File suggestion for you

File top downloads

logo codetitle
Codetitle.com - library source code to share, download the file to the community
Copyright © 2015. All rights reserved. codetitle.com Develope by Vinagon .Ltd