Search This Blog

09 September 2011

Calling Javascript when JQuery UI Tab is selected or clicked

 Recently I had a requirement in one of my project. I am using JQuery UI Tabed view and what I required was to send an Ajax call when a tab is selected. At the start I find it tough to capture onClick or onSelect event of tabs. But later on I got the solution, I would like to share it with all of you. In below given example I put both solutions that I found to capture if a tab is clicked or selected.



26 May 2011

Creating a scrollable table with fixed row and column

To create a Scrollable Table you will need to download JQuery library and jquery.fixer plugging from http://plugins.jquery.com/project/fixer

On this page when you click on download link, a zipped folder will get downloaded. Unzip that folder and then copy "jquery.js" and "jquery.fixer.js" files into the folder where your webpage exist.

To create a scrollable table into your webpage, all you need to do is include "jquery.js" and "jquery.fixer.js" files in your webpage and then on document.ready event, for the table on which you want to enable scrolling call fixer function from "jquery.fixer.js" file. For more detail, see the demo code given below.


16 May 2011

How to set the focus to a child window without refreshing it?

Recently I had a requirement, in my web page which contain four links, each link open a popup window. I am using a common JavaScript function to open popup window as given below,












Now when click on a link, it opens a popup window, which contain a data entry form, I entered some information into that form. Then I need to review other information, from other popup window, so I go back to the main window, click on another link, a new popup window get open which contain the information I need to review. I get the information and close this popup window, so now I am on the main window, then again I click on the link for that data entry form, so the popup window comes up but I lost the information that I have entered, that's because I am relodiing the popup window once again. So here the question arise,
  1. Is their any way, I can check out the if popup window is already open from parent window, without having the object of popup window just by the name?
  2. If the popup window is already open how can I just set the focus to it, rather then reloading it?
  3. Can I refer a popup window from a parent window, even after refreshing the parent window?
And finally I got the solution for all the questions. Make some changes in the function as given below and it start working the way I want it,
















Let us see how it works,
  • When attempt to open the window again with the same name in the second parameter of the windows open method, you will to get the windows handle. If the window is already open, it will return the handle of the opened window or it will open a new window and return it's handle
  • The first parameter (the url) is passed as an empty string, so the page will not get redirected which will result in the contents of the window remaining unchanged.
Note : You cannot get the handle if the page is not on the same host as its opener

13 March 2011

Add & Remove values to a Multi Select list box using JQuery

This control is used to add value to a multiselect list box. And to remove multiple values fron this list box.


Where this control can be useful?
Consider the requirement for adding attributes along with it values (eg. attribute colour with values like red, green, blue... where the number of attribute values are not fixed). Is's good to use this control for adding multiple attribute value, rather then having a seperate screen to add the values.

JQuery Script to add table row and column dynemically

13 February 2011

What is a temporary table?

A temporary table is an object that is created and stored temporarily by SQL Server in the tempdb database. The table can be created by any user by using either the CREATE TABLE statement or SELECT…INTO statement. Temporary tables are of the following two types:


1. Local: A local temporary table is created by prefixing the table name with a single hash(#) sign. The table is visible only to the user who created it.

2. Global: A global temporary table is created by prefixing the table name with a double hash(##) sign. The table is visible to all the users who are connected to the database engine.

The syntax of creating a temporary table is as follows:
To create a local temporary table.

  •  CREATE TABLE #temporary_table ( column1 datatype, column2 datatype)
  •  SELECT * INTO #temporary_table FROM original_table
To create a global temporary table.
  • CREATE TABLE ##temporary_table (column1 datatype, column2 datatype)
  • SELECT * INTO ##temporary_table FROM original_table

06 February 2011

What is an endpoint?

In SQL Server 2005, a connection between servers is managed through an endpoint. The endpoint is an object in SQL Server 2005 through which SQL Server computers communicate with each other over the network. For database mirroring, a SQL Server computer requires a dedicated database mirroring endpoint. The database mirroring endpoint is used to communicate between the servers. It uses the TCP protocol to send and receive messages between the servers in the database mirroring sessions. Each endpoint listens on a unique TCP port number. Clients do not use the database mirroring endpoint to connect to the principal server.   

01 February 2011

What is synonym in SQL Server?

A synonym is a database object used to create aliases for database objects. It is used to hide the actual name of an object from an application connected to the database. If the object is moved to another schema or server, it does not affect the application. After the object is moved, the path of the synonym should be changed according to the path of the object to which the synonym is associated.

Syntex to create and use synonym:
  • CREATE SYNONYM synonym_name FOR object name
  • SELECT * FROM synonym_name

20 January 2011

Data Migration from MS-Access to PostgreSQL - Problems and Solution

I faced tons of problems while migrating my database from Access-97 to PostgreSQL. After trying with few data migration tools, I found that it's good to use PostgreSQL and Access ODBC driver for data migration.

To check with how to setup and use this ODBC driver please go through,
Setup Access ODBC Driver
Install & Setup PostgreSQL ODBC Driver
Migrate Data from Access 97 to PostgreSQL

Using the steps mentioned in Migrate Data from Access 97 to PostgreSQL post, I was able to migrate almost all the tables, still with few tables PostgreSQL ODBC driver fails to transfer the data. Here are some of those errors, which makes PostgreSQL ODBC driver fail,
  • "ERROR : character 0x9d of encoding "WIN1252" has no equivalent in "UTF8"; Error while executing the query(#7)"
  • "ERROR : character 0xb7 of encoding "WIN1252" has no equivalent in "UTF8"; Error while executing the query(#7)"
  • "ERROR : character 0xbc of encoding "WIN1252" has no equivalent in "UTF8"; Error while executing the query(#7)"
  • "ERROR : character 0x92 of encoding "WIN1252" has no equivalent in "UTF8"; Error while executing the query(#7)"
  • "ERROR : character 0x96 of encoding "WIN1252" has no equivalent in "UTF8"; Error while executing the query(#7)"
  • "ERROR: syntax error at or near :,";
    Error while execution the query (#7)
  • The Microsoft Jet engine stopped the process because you and another user are attempting to change the same data at the same time.
So to get rid of all this error, I developed a PHP script, which will read data from Access table using Access-ODBC driver, and insert it into PostgreSQL server using connection string.This script will solve all character encoding related issue. But for the error like "The Microsoft Jet engine stopped the process because you and another user are attempting to change the same data at the same time." which means the database is corrupted or having some bad sector, it will not allow to copy those records, but for that you can use some debug variable in this script to find out id of those record, then open your access database table, and go to that particular record, move your cursor to each column of that record, and you will come to know which field is creating problem. Once you know the corrupted data, you can move all the data except those problem data
____________________________________________________
 <?php
set_time_limit (0);
$conn=odbc_connect("AccessCon", "" , "");
$pgConn = @pg_connect("host=localhost user=ekta password=ekta dbname=Test");
$rslt = pg_query($pgConn, 'SET CLIENT_ENCODING TO \'WIN1252\';');
if($conn){
  $sql="SELECT * FROM myAccessTable";
  $row=odbc_exec($conn, $sql);
  while(odbc_fetch_row($row)) {
     $field1 = odbc_result($row,1);
     $field2 = odbc_result($row,2);
     $field3 = odbc_result($row,3);
     $strQry = "INSERT INTO myPostgresTable (field1, field2, field3)
                     VALUES('" . addslashes($field1) . "',
                                     '" . addslashes($field2) . "',
                                     '" . addslashes($field3) . "')";
     $rslt1 = pg_query($pgConn, $strQry);
  }
}
$rslt2 = pg_query($pgConn, 'RESET CLIENT_ENCODING;');
odbc_close_all();
pg_close($pgConn);
?>
____________________________________________________

19 January 2011

Setup Access ODBC Driver

Perform following steps to setup Access ODBC Driver

  • Click Start, Settings, Control Panel
  • Switch the control panel to "Classical View", if it's already not in classical view
  • In Windows 2000, XP, Vista ODBC located inside Administrative Tools folder. Double click Data Sources (ODBC)
  • ODBC Data Source Administrator window displays
  • Select System DSN tab and click Add button
  • Select "Driver do Microsoft Access (*.mdb)" from the popup opened.
  • Then "ODBC Microsoft Access Setup" window displays.
  • Type name (We will enter name AccessCon) for Data Source Name and click Select button.
  • Select Database window displays. Find your database and click OK button.
  • Click OK on Microsoft Access Setup window and OK on ODBC Data Source Administrator window.