This text is replaced by the Flash movie.

Archive for the ‘Database’ Category

Cannot Create MSSQL Database.

May 1st, 2010

File Path is compressed Cannot Create MSSQL Database.

While trying to add Database which I want to name "SimpleCMS" to MSSQL server and trying to put it under App_Data folder, I encountered this error.


Error Details:
An exception occured while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)

The file "you mssql db path here" is compressed but does not reside in a read-only database or filegroup. The file must be decompressed. CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
...

Cannot Create Database


Most cases this was cause that the Project folder is inside a compressed drive or under a compressed folder, which will save space for your drive.

I just want to share how I resolved this.

Note: That You can uncompressed only the Project folder and leave other compressed.

I'm using windows XP so what I did was 
1.) Right Click on the folder (Project Folder) in General Tab > Click Advanced
2.) Under Compress or Encrypt attributes
3.) uncheck "Compress Contents to save disk space"

Compression

From here I can now add the database "SimpleCMS" under the App_Folder inside the Project Folder.

Database Added

Cake Baking Models – Cannot see other tables

November 7th, 2009

Problem.
After I updated the database, I added 1 table; relate it to another table, and go to the command line to bake what I did, after typing "cake bake " at the command prompt, I found out that the recently added table was not listed.

Cake PHP Bake Model Problem

 

Reason.
Cake caches your schema. 

Solution.
1.) 
Clear your by deleting all files in your app's tmp//models/
and tmp//persistent/

2.) 
Disable caching in your app's config/core.php // make sure to enable back again in production setup

/**
 * Turn off all caching application-wide.  *  
 */  
Configure::write('Cache.disable', true);

After doing the solution, I can now successfully bake the new table.

Saving changes is not permitted

June 14th, 2009

Error: Saving changes is not permitted


While Trying to update a table inside the database I'm working on(Which will happen alot of course), when I tried to save it... I encounter this annoying error.


Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can’t be re-created or enabled the option Prevent saving changes that require the table to be re-created.


So I tried to Google the Problem... and the solution was quite simple.


http://www.danrigsby.com/blog/index.php/2008/09/26/sql-server-2008-error-saving-changes-is-not-permitted/

Right way to use sql…

March 3rd, 2009
Right way to use sql join with conditions (Displaying no match data).
After hours trying to figure out what's wrong with my query for displaying list of cities with how many Lease/Sale were there. The problem was getting the cities even not yet added on Lease or Sale type, that means I need to list cities that has no match yet or 0 count.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?
global $mainframe;
$ebconfig = &$mainframe->getParams();
$prop_Type = $ebconfig->get('prop_type', "Lease");
 
 
$db_city =& JFactory::getDBO();
$query_city = "SELECT t1.city, t1.id, COUNT( t2.propCity ) AS city_count
FROM #__listing_city AS t1
LEFT OUTER JOIN #__listing_listings AS t2 ON t2.propCity = t1.city
WHERE t2.propType = '$prop_Type' AND t2.published = 1
GROUP BY t1.city
ORDER BY t1.city ASC";
?>


The code above does not display the cities that has no match on another table. The where clause was giving the problem...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?
global $mainframe;
$ebconfig = &$mainframe->getParams();
$prop_Type = $ebconfig->get('prop_type', "Lease");
 
 
$db_city =& JFactory::getDBO();
$query_city = "SELECT t1.city, t1.id, COUNT( t2.propCity ) AS city_count
FROM #__listing_city AS t1
LEFT OUTER JOIN #__listing_listings AS t2 ON t2.propCity = t1.city
AND t2.published = 1 AND t2.propType = '$prop_Type'
GROUP BY t1.city
ORDER BY t1.city ASC";
?>


Instead putting the condition on "ON Clause" after the matching table condition, fixed the problem.

MySQL Delete Duplicate Entries

October 19th, 2006

This Is the Best way to delete duplicate entries in MySQL

alter ignore table table_name add unique index(column_name);

For example your table_name.column_name has “some” duplicate entries the best way to do is to put unique index on the column_name that has duplicates

Is that simple.