Thursday, November 17, 2011

The 'microsoft.jet.oledb.4.0' provider is not registered on the local machine

On Windows 7 64bit and Windows 2008 64bit system a common error may arise when using Microsoft.jet.oledb.4.0 driver. Applications running in 64bit mode may not be able to access this driver. This is because 64bit version of this driver does not exist.

Solution to this problem is as follows:

1. We use 32bit application, 32bit application will be able to access the ODBC drivers

2. If you are a application developer and need to develop a 64bit application which can connect to csv, excel files, etc using ADO.NET. You should use Microsoft Access Database Engine 2010 which is a small redistributable and available in both 32bit and 64bit versions.


Summary:

Issue:
The 'microsoft.jet.oledb.4.0' provider is not registered on the local machine.
Issue is that Application pool is running in 64bit mode, therefore 32bit Jet drivers not accessible.

Solution:
Microsoft Access Database Engine 2010:
http://www.microsoft.com/download/en/details.aspx?id=13255
Use this provider Microsoft.ACE.OLEDB.12.0 to connect with csv, excel, etc files.

Wednesday, September 21, 2011

How to sort Rows/Data in a DataTable

We can sort binding source, data view and data table default view to sort data in a data table. There are following three methods which can be applied:

Method 1:
bindingSource.DataSource = table
dataGridView.DataSource = bindingSource
bindingSource.Sort = "Column_Name"

Method 2:
Alternatively, you can just use a DataView:

Dim view as DataView = new DataView(table)
view.Sort = "Column_Name"
dataGridView.DataSource = view

Method 3:
or change the DataTable's DefaultView:

table.DefaultView.Sort = "Column_Name"

Column_Name is the name of one or more columns on which a sort is required. So a Column_Name can have following values like: "COUNTRY" or "COUNTRY, POPULATION" or "COUNTRY, POPULATION DESC".

Friday, April 8, 2011

SQL Server Management, error 29506

When installing SQL Server Management studio on Windows 7 64bit it gives an error with error code 29506. The problem is we need to start this setup as Administrator. Unfortunately when we right click on the setup file, there is no option to Run as Administrator in the context menu.

A work around to this problem is we start a Command prompt (Console) as Administrator, set directory path to the location of setup file, and type the setup file name and press enter to execute.

Now the setup will start as Administrator and will successfully complete.

Steps:

1. Downloaded setup file SQLServer2005_SSMSEE_x64.msi from Microsoft and saved on my local disk, in my case it is D:\Softwares\SSMSEE\

2. Open start menu and type "cmd" in the search box, you will see "cmd.exe" program

3. Now right click it and select Run as Administrator

4. First change drive by typing D: and press enter

5. Now change directory to setup location, type "cd D:\Softwares\SSMSEE\" and press enter

6. Now type setup file name "SQLServer2005_SSMSEE_x64.msi" and press enter

7. The setup will start and complete successfully. That's all

This might also be the case with Windows 7 with 32bit version, in that case same solution should work.

Wednesday, January 5, 2011

A canvas globalCompositeOperation example



var compositeTypes = [
'source-over','source-in','source-out','source-atop',
'destination-over','destination-in','destination-out',
'destination-atop','lighter','darker','copy','xor'
];
function draw(){
for (i=0;i<compositeTypes.length;i++){
var label = document.createTextNode(compositeTypes[i]);
document.getElementById('lab'+i).appendChild(label);
var ctx = document.getElementById('tut'+i).getContext('2d');

// draw rectangle
ctx.fillStyle = "#09f";
ctx.fillRect(15,15,70,70);

// set composite property
ctx.globalCompositeOperation = compositeTypes[i];

// draw circle
ctx.fillStyle = "#f30";
ctx.beginPath();
ctx.arc(75,75,35,0,Math.PI*2,true);
ctx.fill();
}
}


Reference: developer.mozilla.org/samples/canvas-tutorial/canvas_composite

Sunday, January 2, 2011

Check if a browser supports HTML5

Check if a browser supports HTML5

HTML5 is a new way of developing interactive websites, HTML5 is still a emerging technology but we can already see lot of work being done and browsers supporting this new technology.

Anyone who will develop HTML5 will need to know how he can detect the browser is capable of supporting HTML5? or How he can detect which features the browser is compatible with.

The simplest way to do that is creating a canvas object using document.createElement method. After creating the object we can check if 2D context can be created, here is an example below:

<script type="text/javascript">
function supports_canvas() {
//Check if browser supports canvas
return !!document.createElement('canvas').getContext;
}
</script>

We have a open source solution as well, with help of which we can all the features supported by a browser, this is a javascript include file which can be obtained from Modernizr. We simply need to include this file in the head section, no call to any function, on its include it executes and initialize few boolean properties which can be accessed to check different HTML5 feature support.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Dive Into HTML5</title>
<script src="modernizr.min.js"></script>
</head>
<body>
...
</body>
</html>

The Modernizr.canvas property will return false if your browser does not support the HTML5 canvas API, following check will be used:
if (Modernizr.canvas) {
// let's perform some 2d graphics!
} else {
// no canvas support available!
}

Saturday, January 1, 2011

HTML5 Hello World Application

I consider HTML5 canvas the backbone of all the features available in HTML5, i recently got chance to work on a HTML5 application and really enjoyed learning new things and was really impressed with myself. Actually anyone who already knows some JavaScript and traditional HTML can kick start working on it.

For those who have just started working on it, i have created a Hello world application, this is a simple application, but will give overall view of how it works. Like in our graduation we always create a Hello world application to get start learning things, so here how it works:

First of all we should know whether the browser supports HTML5 canvas, for this you can view my post at Check if browser supports HTML.

I will use following method:
function supports_canvas() {
//Check if browser supports canvas
return !!document.createElement('canvas').getContext;
}


Next we need a Canvas element which supports 2D graphic drawings, it is the canvas on which we can draw different shapes like circle, rectangle, arcs, circle, etc also we can write text, and draw images from some source files.

This sample focuses on creating a canvas and writing hello world on it. For this i will create a DIV element in my document, than add a Canvas element in the DIV using JavaScript:

function initializeCanvas(containerid, canvasWidth, canvasHeight) {
var container = document.getElementById(containerid);
if ( supports_canvas() ) {
//Create canvas element
var canvas = document.createElement('canvas');
canvas.setAttribute('width', canvasWidth);
canvas.setAttribute('height', canvasHeight);
container.appendChild(canvas);
//Context of canvas for performing 2d graphics operations
context = canvas.getContext('2d');
return context;
} else {
container.innerHTML = 'This is a HTML5 app,
you need a HTML5 capable browser like Firefox,
Chrome, Safari or Internet Explorer 9.'

return null;
}
}


Here is the working sample: Sample Hello World