Hi,
Adding a progress bar and updating it without freezing the main UI Form has always been tough for many .NET programmers. Here is a skeleton (demo) application on how to update progress bar on the main window from a secondary thread. This is a skeleton application which you can use as such just by inserting your code snippet in the right place.
Download Source Code (Visual Studio 2008 Project)
You can download and modify the source code for any purpose free of cost.
Wednesday, December 29, 2010
Wednesday, December 1, 2010
"GROUP BY" does not group some data - Why?
"GROUP BY" clause (tested in PostgreSQL) does not group rows by on-the-fly temporary columns included in SELECT statement. For example, the below SQL will not group properly since 'manager_name' column is included in 'GROUP BY'. But, removing it from 'GROUP BY' will work properly.
Erroneous sql:
SELECT emp.name, salary.year, SUM(salary.amount), 'Ela' as manager_name -- On the fly temporary column FROM emp JOIN salary ON salary.emp_id = emp.id GROUP BY emp.name, salary.year, manager_name -- <-- Here is the problem! This should be removed. ORDER BY emp.name, salary.year;Corrected SQL:
SELECT emp.name, salary.year, SUM(salary.amount), 'Ela' as manager_name FROM emp JOIN salary ON salary.emp_id = emp.id GROUP BY emp.name, salary.year ORDER BY emp.name, salary.year;
Monday, November 22, 2010
Introduction to Postgres Stored Procedure
Postgres does not directly seem to support stored procedures. However, it supports it through functions and cursors. Here is an example how to write a stored procedures in PostgreSQL:
1. Create a function that returns a cursor.
CREATE OR REPLACE FUNCTION get_employees(emp_cursor refcursor, dept_id int) RETURNS refcursor AS $BODY$ DECLARE sql_statement character varying; BEGIN sql_statement = 'SELECT id, name FROM emp WHERE dept_id = ' || CAST(dept_id AS character varying); OPEN emp_cursor FOR EXECUTE sql_statement; RETURN emp_cursor; END $BODY$ LANGUAGE 'plpgsql' ;
That's all. Your stored procedure is ready to be accessed from your application code.
2. To call the sp from your code, you need to run two sql statements consecutively within a single transaction. Given below is sample JAVA code (A similar approach/workaround should be available in other languages too):
/* Create your connection object here. */ connection.setAutoCommit(false); /* The above is required since every statement will be committed automatically by default. If your language does not support the above methodology, try database level transaction with BEGIN END statements. */ Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery("SELECT get_employees('emp_cursor', 1);"); resultSet = statement.executeQuery("FETCH ALL IN emp_cursor;"); /* Do whatever stuff you want to do with the result set. */ connection.commit(); //Commit the transaction connection.close();
Labels:
pg,
postgres,
postgresql,
sp,
stored procedure
Thursday, August 12, 2010
Wicket quickstart modifed for request response
Download Project Source
This is the first time I am trying a JAVA application (10 years back I had just opened the big JAVA book and left it as such and fully concentrated on C++ and .NET). The above application is a modified version of the quickstart wicket project available in apache website. I have modified it to a request response application which is quite easy to understand if you are a C++ or .NET programmer. (You must have some basic knowledge about wicket)
1. Initial Screen |
2. Enter something and click "Update" |
3. Resulting page |
Tuesday, July 27, 2010
Apache wtih PHP - Ready to use Installation Package
This is a readymade PHP-Apache installation package to work with PHP on Apache Web Server on Windows. Simply download and install the setup. Your PHP development enviornment will be ready right away. This package comes with the following:
PHP Version 5.2.6
Apache Version 2.2.10 (Win32)
PHP MySQL extension
NOTE: Apache will be installed to port number 9090.
Download Setup
This setup is suitable for development environments only. Extra care/settings should be considered for production environments.
PHP Version 5.2.6
Apache Version 2.2.10 (Win32)
PHP MySQL extension
NOTE: Apache will be installed to port number 9090.
Download Setup
This setup is suitable for development environments only. Extra care/settings should be considered for production environments.
Thursday, July 22, 2010
Monday, July 19, 2010
Plugin to view Adilife Profiles with Photo
Click here to download setup.
This is a plugin for Pattukottai KMV www.adilife.com. I am a registered member of adilife.com and developed this for my personal use. This plugin is a local application done using Apache and PHP (I am not a well-versed PHP programmer, so forgive me for any bugs.). I have been using this for quite a few months and is useful. This plugin will work until there are no changes or upgrades to adilife pages. (Noted as on 26/07/2010.). If you see any problems with this plugin, please drop me a message.
Advantage of this add-in:
Currently adilife.com does not display profile-photos in search results. This add-in will make the search results display photographs. This saves a lot of time and makes you visit every profile in adilife.com in a very short period of time. Also, this is not a complete application, so some adilife pages may not work as expected. In such cases, please login to www.adilife.com directly to visit such pages.
Instructions to use:
1. Download the installer and install it on your Windows machine. Install it to the location suggested by the installer to avoid possible bugs. Click here to download setup.
NOTE: Vista Users must run the application as Administrator.
2. Once the installation is over, click on "Adilife Plugin" Desktop shortcut icon.
3. You must see adilife login page. You need to login to adilife through this page.
Attention Vista Users (XP users can skip this and go to next step):
On Windows Vista, if you see any error like "Page not found", then run "cmd" (command prompt) as administrator. From command prompt, type the following and press enter:
C:\AdilifePlugin\apache-install.bat.
Now, follow from step 2.
4. After logging in, search for profiles. You must see the results getting displayed with photographs.
You can also shortlist profiles and view them all in one single page. You can even organize the profiles. See the available options here:
Use the menu displayed on top of every page to see your organized profiles.
Instructions to Uninstall:
Start Menu ==> Programs ==> Adilife Plugin ==> Uninstall Adilife Plugin
This is a plugin for Pattukottai KMV www.adilife.com. I am a registered member of adilife.com and developed this for my personal use. This plugin is a local application done using Apache and PHP (I am not a well-versed PHP programmer, so forgive me for any bugs.). I have been using this for quite a few months and is useful. This plugin will work until there are no changes or upgrades to adilife pages. (Noted as on 26/07/2010.). If you see any problems with this plugin, please drop me a message.
Advantage of this add-in:
Currently adilife.com does not display profile-photos in search results. This add-in will make the search results display photographs. This saves a lot of time and makes you visit every profile in adilife.com in a very short period of time. Also, this is not a complete application, so some adilife pages may not work as expected. In such cases, please login to www.adilife.com directly to visit such pages.
Instructions to use:
1. Download the installer and install it on your Windows machine. Install it to the location suggested by the installer to avoid possible bugs. Click here to download setup.
NOTE: Vista Users must run the application as Administrator.
2. Once the installation is over, click on "Adilife Plugin" Desktop shortcut icon.
3. You must see adilife login page. You need to login to adilife through this page.
Attention Vista Users (XP users can skip this and go to next step):
On Windows Vista, if you see any error like "Page not found", then run "cmd" (command prompt) as administrator. From command prompt, type the following and press enter:
C:\AdilifePlugin\apache-install.bat.
Now, follow from step 2.
4. After logging in, search for profiles. You must see the results getting displayed with photographs.
You can also shortlist profiles and view them all in one single page. You can even organize the profiles. See the available options here:
Icon | Option |
---|---|
Shortlist | |
Interest Sent | |
Interest Received | |
Rejected | |
Clear | |
Move |
Use the menu displayed on top of every page to see your organized profiles.
Instructions to Uninstall:
Start Menu ==> Programs ==> Adilife Plugin ==> Uninstall Adilife Plugin
Thursday, July 8, 2010
Connecting to SQL Server from C#.NET
Download Project and Source Code
Using the above .NET 2005 Project, you can connect to your SQL Server Default Instance and test the connection.
Possible issues:
1. Unable to connect to SQL server or MSDE 2000 from remote machine/another machine.
2. Unable to connect to SQL Server or MSDE 2000 from Code.
Resolution:
Change your firewall settings and add an exception to the port 1433. Or turn off firewall. And then follow these steps.
Step 1: Open SQL Server Configuration Manager
Step 2: Enable TCP/IP Connections
Step 3: Start Menu => Run
Step 4: Type services.msc and press OK
Step 5: Restart SQL Server
Using the above .NET 2005 Project, you can connect to your SQL Server Default Instance and test the connection.
Possible issues:
1. Unable to connect to SQL server or MSDE 2000 from remote machine/another machine.
2. Unable to connect to SQL Server or MSDE 2000 from Code.
Resolution:
Change your firewall settings and add an exception to the port 1433. Or turn off firewall. And then follow these steps.
Step 1: Open SQL Server Configuration Manager
Step 2: Enable TCP/IP Connections
Step 3: Start Menu => Run
Step 4: Type services.msc and press OK
Step 5: Restart SQL Server
Thursday, June 17, 2010
DOS MineSweeper with GUI
This DOS MineSweeper game using C graphics was developed by me in the year 2000 when I was doing my B.Tech 2nd year at Pondicherry Engineering College. It was the time when I had just started to learn C and C++. I am sharing the code here without any modifications for people who are interested in learning graphics programming using C/C++. This application uses mouse interface and looks like a windows application when run(hoping so ;-) ). Since I was a newbie that time, I wrote this program in an adhoc way. But I recommend the beginners to organize their code in a much better way and add plenty of comments wherever possible.
Platform: MS DOS
Compiler: TURBO C++ 3.0
The entire code can be put in one single .cpp file. Should you require any help to compile this code and make it run, do not hesitate to drop me a message.
Download Source Code
Free Blog Counter
Subscribe to:
Posts (Atom)