Search This Blog

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);
?>
____________________________________________________