Search VB 2010

Tuesday, April 14, 2015

MS Access 2003/2007/2010 Compact and Repair

VB.Net Compact and Repair Database - MS Access

Neither ActiveX Data Objects (ADO) nor ADO .NET provide the means to compact or repair Microsoft Access databases. However, you can accomplish this task by using the Microsoft Jet OLE DB Provider and Replication Objects (JRO) that was introduced with Microsoft Data Access Components (MDAC) version 2.1. ADO .NET allows the use of COM-based object libraries through the Interop layer.

This article demonstrates how to compact an Access database by using Visual Basic .NET.

Requirements

Microsoft Visual Basic .NET

Microsoft Jet and Replication Objects 2.1, 2.5, or 2.6 Library

Steps to build example

Open a new Visual Basic .NET console application.

In the Solution Explorer window, right-click the References node and select Add Reference.

In the Add Reference dialog box, click the COM tab, and then select Microsoft Jet and Replication Objects 2.x Library. Click Select to add it to Selected Components. Click OK.

Note In this step, x is a placeholder for the actual version number of the Microsoft Jet and Replication Objects Library component.

A warning will be displayed if there is no wrapper found for the selected library. Click Yes to generate a wrapper. Microsoft ActiveX Data Objects Library (ADODB) and JRO references will be added to the project's References.

Change the path to the Source and Destination .mdb files as appropriate. Press F5 to build and run the project.

The compacted database will be in Access 2000 (Jet 4.0) format. For a different Jet format, see "References."

Pitfalls

In order to compact a database, the Jet Database Engine requires exclusive access to the database file. Attempting to compact a database file that is currently in use will result in an exception. This exception can be caught using a Try...Catch structure.

Sunday, April 13, 2014

Could not load file or assembly 'file:///C:\Program Files\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet1\crdb_adoplus.dll' or one of its dependencies. The system cannot find the file specified. how can solve this error in windows application

Solution
Add those lines to your App.Config file located in your VB2010 Solution Explorer Panel
and Run your application again.

Error (2)

Crystal Reports Database Login box. Some time Crystal Reports run perfectly on your machine (Developer Machine) but after deploying it and install it on another Machine, it gives you an error like this :

VB2010 Crystal Reports Database Location Error

Solution
Add those lines to your Form_Load where the report is being loaded to adjust the Database location (Microsoft Access 2003 Database) :

I've tried many sites and many solutions but I've never figured out the error pattern, or why does Crystal Reports not letting me insert any photo of any kind (JPEG, JPG, PNG) or resolutions. But I landed on this solution and it is working fine with me, and it seems the only solution I've now :

1) Right-click on the report while in the design

2) Choose Insert, then choose Picture

3) Single Left-click the on the photo you wish to insert

4) Click Open, you will notice the image box appears on the report

5) Place the Image box any where on the report and you will see it there.

- I used to double-click the image in the Dialog Box where I choose the Image but that did not work with me, now when I use 'Open', it is working 'Silly'

This happens when we try to connect the Crystal Report with MS-Access Database in VB 2010 using the code (Programmatically).

Note that it won't happen we connect the Crystal Report with access protected database using the wizard, we just use the (Jet Database Password) field instead of (Database Password) field to provide the report with your Database Password.

VB 2010 Crystal Report MS-Access Password Protected Database

But, to do this programmatically using code in VB 2010, you notice you always get "Logon Failed" Error message, using something like this :

And you get this error message :

Solution
After many trials and tests, I've found out the only solution for this problem is to connect dynamically to Crystal Reports in VB 2010 using code is through the DataSet and DataTable Objects, here is the code to accomplish this :

Wednesday, February 12, 2014

Visual Basic Online Course

How to make sure that an Application is Running and Installed

Visual Basic Online Course - Tips

When you create a Visual Basic 2010 or generally a VB.Net application that relies on another VB.Net application for example an Updater.exe application, you will have to code both sides in order no to enable the user to run Updater.exe without the existence of the Main application, and in order to do so, you will have to make sure that :

1) Your Main application is Running.

2) Your Main application is Installed.

3) Your Main application does exist in the installation folder.

After making sure of all the above points, then you can compile your updater.exe file with your Main Application knowing that updater.exe won't run alone, especially if you're sending updates to the Main application for the user to receive using Updater.exe.

Here are the code to do so :1) VB 2010 Get list of all installed applications