Search This Blog

Thursday, December 17, 2009

Failed to create the Crystal Query Engine Visual Studio 2005

When try to open crystal report in VS 2005, error message appear "Failed to open document" and followed by message "Failed to create the Crystal Query Engine".

I believe it same case with what discuss in http://social.msdn.microsoft.com/Forums/en/vscrystalreports/thread/79e1da80-f5c6-42fa-80ca-65a10de5729d .

The root cause maybe because of installation and uninstallation of merge module. Many recommend that we remove the crystal report, after that add crystal report back to visual studio. Steps below

  1. Go to Add/Remove Programs and select Change/Remove for Microsoft Visual Studio 2005
  2. Select Next then Add or Remove Features from the Visual Studio 2005 Maintenance Mode app
  3. Uncheck Crystal Reports for Visual Studio and select Update
  4. Once the "Update" is complete, select Finish
  5. Go back to Add/Remove Programs and select Change/Remove for Microsoft Visual Studio 2005
  6. Select Next then Add or Remove Features from the Visual Studio 2005 Maintenance Mode app
  7. Check Crystal Reports for Visual Studio and select Update
  8. Insert Disk 1 of Microsoft Visual Studio 2005 Installation CD's and select OK
  9. Once the "Update" is complete, select Finish

But in my case, i don't have installation CDs with me. So, i try an alternative way to get it work. You can try it but at your own risk.

I have another development machine which i call it machine B which have VS 2005 with crystal report install and working fine. The one have problem, i call it machine A. What i do is:

1. go to machine B, go to folder C:\Program Files\Common Files\Business Objects\2.7
2. copy the whole bin folder to a external drive or pendrive or thumb drive
3. close the visual studio 2005 in machine A if it's open
4. go to machine A, go to folder C:\Program Files\Common Files\Business Objects\2.7 and rename the bin folder to binA for backup purposes
5. copy the bin for the external drive to C:\Program Files\Common Files\Business Objects\2.7 in machine A
6. try to open visual studio 2005 and open the crystal report development file.
7. it working

It solve my problem especially when i don't have the installation cds with me at the moment. Hope this help

Saturday, December 12, 2009

Error 0xc00470fe: Data Flow Task: The product level is insufficient for component "Source - data1$" (1)

Trying to import data from a text file using MSSQL2005 SSIS import and export wizard to import data from email.txt into MSSQL data and found below error.

Error 0xc00470fe: Data Flow Task: The product level is insufficient for component "Source - email_txt" (1)

Surf around and found that it's a bug for MSSQL2005 SSIS and have fix in MSSQL SP2. So, try to download SP for mssql and it do solve my problem.

Thursday, November 19, 2009

delay open file when startup with batch files

I have come across a need to start 2 application during window start up by sequence. The 1st application i call it App1 (C:\application\App1.exe) and the 2nd one i call it App2 (C:\application\App2.exe). Check the below script, REM mean comment in command prompt.

REM set command display to off
@echo off

REM start application App1.exe
START C:\windows\notepad

REM wait for 5 seconds
PING -n 5 localhost > nul

REM start application App2.exe
START C:\windows\notepad

REM exit batch after finish
EXIT

To test it, Open window notepad. Copy and paste code above to the notepad and save as "start.bat". To make it simple for testing, i have change C:\application\App1.exe to C:\windows\notepad and C:\application\App2.exe to C:\windows\notepad.

Double click on start.bat and you can see the batch file in action.

Hope this help.


Saturday, November 14, 2009

Ping port

Well, sometimes we need to know whether the port in open or block, we need to do some checking or troubleshoot through ping/telnet. We cannot ping a IP with port but we can telnet certain IP together with Port no.

For example:
Go to open command prompt, if we want to check whether port 21 is working for IP 203.166.87.9 what we need to do is
> telnet 203.166.87.9 21

Thursday, November 12, 2009

Method not found: 'Void System.Web.UI.ScriptManager.RegisterStartupScript

Deploy a running web application from one windows 2003 server to another windows 2003 server. The application is running asp.net 2.0 framework with Ajax.net v1, MSSQL 2005.
After deploy everything and run the application, Error message

Method not found: 'Void System.Web.UI.ScriptManager.RegisterStartupScript(System.Web.UI.Page, System.Type, System.String, System.String, Boolean)'

Situation:
In the bin folder, we deploy together with
AjaxControlToolkit.dll
AjaxControlToolkit.pdb
System.Web.Extensions.Design.dll
System.Web.Extensions.dll

After look around and found that the server already installed with the same version but the strange thing is the file size are different from the one i have in bin folder. The first thing can thought of is reinstall the ajax.net.

No luck, after the ajax.net reinstallation, it's not work. Still the same error message:

Method not found: 'Void System.Web.UI.ScriptManager.RegisterStartupScript(System.Web.UI.Page, System.Type, System.String, System.String, Boolean)'

Try to delete all 4 dlls
AjaxControlToolkit.dll
AjaxControlToolkit.pdb
System.Web.Extensions.Design.dll
System.Web.Extensions.dll
from the bin folder but still same error show. So, i undo the deletion.

Try to google around and look for useful suggestion but no luck. All post stated that working after the ajax.net re installation.

Finally, i uninstall the ajax.net from the server and let the application use the 4 dlls
AjaxControlToolkit.dll
AjaxControlToolkit.pdb
System.Web.Extensions.Design.dll
System.Web.Extensions.dll
in the bin files.

It solve my problem.

Hope this sharing helps.

Monday, November 9, 2009

Penang Software House

We are running a software development company Encelabs Sdn Bhd located in Penang, Malaysia. Basically Encelabs provide web application customization like web2.0 community website, facebook application and etc. Encelabs also provided services to develop business software development like eCRM, eProcurement, eRecruitment and etc from A to Z. Some of Encelabs portfolio are listed in Encelabs website.

Feel free to contact Encelabs to know more.

Sunday, October 11, 2009

PHP: Warning: split() [function.split]: REG_EMPTY in xxx

I try to php split to split out the concatenated data. Below are the sample that i use

$comp = "V1001|VI003";

$comp_arr = split("|",$comp);

i hit error:

PHP: Warning: split() [function.split]: REG_EMPTY in xxx

after search around and found that the issue is caused by symbol "|".
"|" is an operator in PHP. If want to use the this symbol as a delimiter, we must excape it with a back slash, "\|"

now it become

$comp = "V1001|VI003";

$comp_arr = split("\|",$comp);

and it works.

Hope this help

Wednesday, October 7, 2009

using jquery in Joomla

I'm developing a joomla component for joomla and involve jquery. It will hit error and need to take special care because joomla ship with javascript framework "MooTools" which will have conflict with jquery.

Here is the code that i pun into my view.html.php

$document =& JFactory::getDocument();
$document->addScript(JURI::base(true).'/components/com_xin/js/jquery-1.3.1.min.js');
$document->addScriptDeclaration ( 'jQuery.noConflict();');
$document->addScript(JURI::base(true).'/components/com_xin/js/validation.js');

in the validation.js

I change all the $ to jQuery.

For example i change
$(document) to jQuery(document)
$('#login') to jQuery('#login')
and all others.

Test again and it works. Hope this help.

Friday, October 2, 2009

LoadLibrary ("xxxx.dll") failed - The specified module could not be found

I've created a dll using VC++ and try to register the dll in the machine xp pro using regsvr32. I copy the dll from my development machine to the deployment and hit error message.

LoadLibrary ("xxxx.dll") failed - The specified module could not be found.

What's go wrong?

I already make sure all my dll dependency copied to the machine. Finally i found out that i should compile the dll in debug mode only. I should compile it in release mode.

I'm able to register to the xp machine after i compile in release mode. Hope this help.

odbc: data source name not found

Situation:

The application written in ASP with dll and etc and use ODBC for database connection. Everything working fine but one day there was a auto windows update can cause this ASP application running with error message "data source name not found". Plenty of time taken for debugging and not solved. Finally by trial and error, the problem solved. Strange, the problem is caused by the permission setting on the dll which call the ODBC. We suspect the problem cause by the windows update and change the permission setting.

Hope this help.

Sunday, September 27, 2009

phpsoap: retrieve returned array data

Well, i'm newbie in soap especially phpsoap. I'm facing problem to retrieve data returned from a soap api written in .net. I can see the whole data printed out by using print_r but i'm not able to get the each data from the array returned.

Situation:
I want to get the data returned by the soap server in array form after i've called the function "GetAccountInfo" by passing in parameter "AccoundID" by using phpsoap client.
My soap server url: http://10.10.100.101/soapserver.asmx

below are the code that i can get the data printed out.
<?php
$ini = ini_set("soap.wsdl_cache_enabled","0");

//instantiate the SOAP client
$client = new SoapClient("http://10.10.100.101/soapserver.asmx?WSDL");

$params = array();
$params["AccountID"] = "inblues";

$result = $client->GetAccountInfo($params);
print_r ($result ->GetAccountInfoResult);

?>

Output on the browser:


Array (
[GetAccountInfoResult] => Array (
[memberData] => Array (
[lastlogin] => 6/19/2009 2:10:51 AM
[lastip] => 219.95.192.254
[datecreated] => 6/19/2009 2:10:51 AM
[active] => 1
)
)
)



But what i want is only [active] field's data. What can i do? Finally, by looking at the printed result and by try and error, i found out that it's a 3 dimensional array, below code helps me to get the data i want.

<?php
$ini = ini_set("soap.wsdl_cache_enabled","0");

//instantiate the SOAP client
$client = new SoapClient("http://10.10.100.101/soapserver.asmx?WSDL");

$params = array();
$params["AccountID"] = "inblues";

$result = $client->GetAccountInfo($params);

// the result is in 3 dimensional array
print_r ($result->GetAccountInfoResult->memberData-> active);

?>

Solve. I get my value 1 printed out in the browser.

Friday, September 25, 2009

remove "Google Toolbar" from firefox

Open Mozilla Firefox,
Go to Tools Menu, Click On Add-ons




A new Add-ons windows popup, Select "Google Toolbar for firefox" and click on Unistall button.



Done. Hope this help.

Thursday, September 3, 2009

The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use .. pool

Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool.
This may have occurred because all pooled connections were in use and max pool size was reached.

My web app written is ASP.NET C# and database use MySQL.

To solve it. Close all your connection each time you have finishing your query.

Monday, August 24, 2009

Sys.WebForms.PageRequestManagerServerErrorException: an unknow error occured while processing the request on the server. ..status code returned .. 500

My situation:
Environment: ASP.NET, AJAX.NET and MySQL DB

I got error return when using one of the form written in AJAX.NET when calling MySQL Stored Procedure

Sys.WebForms.PageRequestManagerServerErrorException: an unknow error occured while processing the request on the server. the status code returned from the server was: 500



Well, after check around i found out that the problem is in the MySQL Stored Procedure case sensitive issue. Change the case and problem solved!

Wednesday, August 19, 2009

phpmyadmin and stored procedure

As far as i know, we are not able to view, edit stored procedure using phpmyadmin but we are able to drop/create stored procedure using phpmyadmin.

I try to create a mysql stored procedure using phpmyadmin and hit error below

Error

SQL query:

DELIMITER;

MySQL said:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER' at line 1




my original code:

DELIMITER $$

DROP PROCEDURE IF EXISTS `xxxweb`.`pp_pspbatch` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `pp_pspbatch`(
IN pBatchName VARCHAR(255),
IN pCountryID INT
)
BEGIN

xxxxx
xxxxx
xxxxx

END $$
DELIMITER ;

try below steps, it help to solve my problem
1. Go to any SQL tab in phpMyAdmin.
2. Directly below the SQL text area you'll see a text input labeled "Delimiter." In that field, enter "$$".





3. Modify the script become like below

DROP PROCEDURE IF EXISTS `xxxweb`.`pp_pspbatch` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `pp_pspbatch`(
IN pBatchName VARCHAR(255),
IN pCountryID INT
)
BEGIN

xxxxx
xxxxx
xxxxx

END $$

and run it. It works.

Wednesday, July 22, 2009

SmarterMail not receiving mails but can send out email

Well, set up my smartermail in new windows 2003 server. I've already make sure steps provided in Smartermail help file properly set.

WebMail URL (A Record) - Add an A or CNAME record for mail.example.com that points to the IP address of the webmail interface. This will allow users of that domain to access the webmail by typing in http://mail.example.com or http://mail.example.com:9998 in their web browser (depending on whether you use the included web server or IIS).

Mail Pointer (MX Record) - Add an MX record for example.com that points to the IP address that you assigned when adding the domain to SmarterMail. This will allow other email servers to locate your mail server.

Reverse DNS Record - Add a reverse DNS record for IP addresses assigned on the server to provide extra assurance to other mail servers. Also, it is recommended that the primary IP address of the server also have a reverse DNS record. Note: Adding reverse DNS may also require a change at your isp.


Also already setup iis to able login thru specific domain. Things work fine, able to send out email but not able to received email from external domain that not in the server. Strange, huh?

After check here and there, finally find out that we need to enable port in windows firewall.

Well, open my windows firewall and add in "Exceptions" to the port correctly. For my case, i just enable the port for below port



It's work. Hope can help.


Monday, July 13, 2009

#1064 - You have an error in your SQL syntax; xxx corresponds to your MySQL server version for the right syntax to use near 'DELIMITER' at line 1

I try to create a mysql stored procedure using phpmyadmin and hit error below

Error

SQL query:

DELIMITER;

MySQL said:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER' at line 1




my original code:

DELIMITER $$

DROP PROCEDURE IF EXISTS `xxxweb`.`pp_pspbatch` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `pp_pspbatch`(
IN pBatchName VARCHAR(255),
IN pCountryID INT
)
BEGIN

xxxxx
xxxxx
xxxxx

END $$
DELIMITER ;

try below steps, it help to solve my problem
1. Go to any SQL tab in phpMyAdmin.
2. Directly below the SQL text area you'll see a text input labeled "Delimiter." In that field, enter "$$".





3. Modify the script become like below

DROP PROCEDURE IF EXISTS `xxxweb`.`pp_pspbatch` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `pp_pspbatch`(
IN pBatchName VARCHAR(255),
IN pCountryID INT
)
BEGIN

xxxxx
xxxxx
xxxxx

END $$

and run it. It works.

Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0

this will happen in linux server when the owner permissions is set to read/write/execute only. There is no public and group permissions setting. To solve this, i can the permissions to 755.

Problem solved.

Thursday, July 2, 2009

Reverse 2 dimentional array in C/C++

I need to reverse 2 dimentional array in C/C++.
Example: i need to reverse
10010110 t0 01101001
10000000 to 00000001

my 2 dimention array:

myArray[0][0] = 1
myArray[0][1] = 0
myArray[0][2] = 0
myArray[0][3] = 1
myArray[0][4] = 0
myArray[0][5] = 1
myArray[0][6] = 1
myArray[0][7] = 0

myArray[1][0] = 1
myArray[1][1] = 0
myArray[1][2] = 0
myArray[1][3] = 0
myArray[1][4] = 0
myArray[1][5] = 0
myArray[1][6] = 0
myArray[1][7] = 0

//in main
void main()
{

//call function
reverseArray(myArray, 2);

}

// function reverseArray
void reverseArray(char array[][8], int row) {
int i;
int j;
int size;
char swap;

for (j = 0; j<=(row-1); j++)
{

i=0;
size = 8;

for(i;i<--size;i++)
{
swap=array[j][i];
array[j][i]=array[j][size];
array[j][size]=swap;
}
}
}

this return the value i need. Hope this help

Friday, June 5, 2009

PHP call external cgi and process responses

This is tough for me. First time to code in PHP with cgi and don't know how to start. Thanks google for this.

My task is call a cgi script to execute some function and process the return data. Well, here i'll mention on how to call external cgi and the process part can be settled using PHP string processing.

Let's start by example:

cgi domain location: www.xincube.com/script/handler/api.cgi

The code will strip header below and return the content of the response data.

HTTP/1.1 200 OK
Date: Sat, 06 Jun 2009 02:23:33 GMT
Server: Apache
Proxy-x-forwarded-for: 203.116.10.206
X-returncode: 0
X-returndesc: Access denied
Cache-control: no-cache
Pragma: no-cache
Connection: close
Transfer-Encoding: chunked
Content-Type: text/plain

We can do anything we want to get the information we need in $content.

CODE:

/* sample for calling cgi */
$host = 'www.xincube.com';
$path = '/scripts/handler/API.cgi';

$data_to_send = 'action=GetSupportedData';


PostToHost($host, $path, $data_to_send);

/* function that will call cgi */
function PostToHost($host, $path, $data_to_send) {

$header = "not yet";
$content = '';
$fp = fsockopen($host,80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)\n";
}
else {
fputs($fp, "POST $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: ".strlen($data_to_send)."\n");
fputs($fp, "Connection: close\n\n");
fputs($fp, $data_to_send);

while(!feof($fp)) {
//echo fgets($fp, 4000);
$line = fgets( $fp, 4000 );
if( $line == "\r\n" && $header == "not yet" ) {
$header = "passed";
}
if( $header == "passed" ) {
$content .= $line;
}
}
echo $content;
fclose($fp);
}
}


Hope this help. Support me to write more by clicking on the ads sponsor or donation. Thanks

Tuesday, May 19, 2009

MySql.Data.MySqlClient.MySqlException: Table 'xxx.xx_XxxxXxx' doesn't exist

Hit error when try to connect to MySQL in Linux from ASP.NET in IIS6. Seriously, the table is 100% Exist in the database but i hit error below:

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: MySql.Data.MySqlClient.MySqlException: Table 'xxx. xx_XxxxXxx' doesn't exist




Well, finally find out that it caused by case sensitive on the table name. After i've change the name, it's work perfectly.


Monday, May 18, 2009

Access denied for user 'xxxx'@'xxx.xxx.xxx.xxx' (using password: YES)

Well, my scenario is connecting my ASP.NET 2.0 apps from IIS6 (window 2003 server) to MySQL (Linux) using ADO.NET Connector.

Hit error message when try to connect:
Access denied for user 'userxxx'@'xxx.xxx.xxx.xxx' (using password: YES)



It's quite worry because this is first time trying to connect from a .net web application is IIS to MySQL in Linux.

Prior to that, privileges must be granted in MySQL.
______________________________________________
mysql> grant all privileges on *.* to 'userxxx'@'xxx.xxx.xxx.xxx'
identified by 'xxxpasswordxxx' with grant option;
Query OK, 0 rows affected (0.00 sec)
______________________________________________

Finally, found that it's my own mistake. I've put in the wrong username and password. Check your username and password seriously before the connection.

Saturday, May 16, 2009

Add more than one column to a table in MySQL

Sometimes we might need to add multiple column to a table in MySQL, sample below work perfectly

ALTER TABLE pp_batch_detail
ADD `user_id` int(10) unsigned default NULL,
ADD `user_name` varchar(255) default NULL,
ADD `date_request` datetime default NULL;

Sunday, April 12, 2009

Never try http://www.internet-webhosting.com/

I'm customer for SKSA Technology - http://www.internet-webhosting.com/ . Trust me, don't ever try your luck.

We first subscribe to the windows hosting in May 2007, at first we feel that this hosting company is ok and professional because they really give a impressive respond time in handling ticket. So, we put in another 2 domain with asp application & sql express in it. Since then, we can see the problem come.
1. The readable and writable folder become read only and hit us error.
2. The database always cannot be used.
3. Harddisk crash
4. Domain server not found

They are not sincere in telling the truth. They take out all the notice and promises. Example case:

In 24 Nov 2008, No response for ticket and email. Nothing has been done. Can you image? We have made the decision to migrate the application to another hosting company with another domain. We use the previous backup application and database.

25 Nov 2008, No response for phone call and a statement come out in https://support.internet-webhosting.com/index.php?_m=news&_a=viewnews&newsid=66 which has been bring down from the web a few days after that.

26 Nov 2008, they come out a statement saying that all the web is up but 2 of my application/domain still down.

27 Nov 2008, the new domain from another hosting company up and running but the internet-webhosting.com. We give up on chasing the old domain and we focus on the new domain.

28 Nov 2008, finally we can backup the old DB and send to the new hosting to setup for the latest DB. Can you image that it takes us 5 days to settle everything. Moving out from www.internet-webhosting.com is the best choice. 

After that case, there is a post in their website and saying will pay for the lost like free hosting for 3 months and etc but has been taken out after few days. Is this how they work? Where is the sincerity? 
This is the link

content:
__________________________________________________________________
UPDATES : 26th November 2006 (10.50am)
======================


We would like to inform you that we have recovered all the shared hosting server except for the following server :

1. Windows Server (124.217.243.54) = DNS Isssue
- Expected Resolution Time 6 hours.

2. Linux Server (124.217.243.100) = Disk Corrupted Issue.
- Expected Resolution 10 Hours.
- We are restoring all the site using the latest backup copy available.


Due to this unfortunate Event, our management have decided to give the following options to the affected client :

1. We will give 3 month time extention of the affected hosting account.

Or,

2. Will will give RM10 credit and add it as a Live Credits in the client account with us . This credit can be used to purchase our services and cannot be withdraw.

Kindly sent email to credits@internet-webhosting.com to choose one of the above options for redemption.

Thank you.

__________________________________________________________________

Above has been taken out after the downtime. Dont try to do this to your customer. 

WHAT A DISASTER!

On and off, there are cases which is very annoying. Yesterday night 13 April 2009, their harddisk crash again! We only left one domain and application but we will migrate it to new hosting company once we get the backup some times end of this week?

They never listen to customer's complaint. Ironicly, they are top 5 in malaysia http://www.webhosting.info Is Malaysian really can stand for their services?

Our requirement is simple, 
1. Not email interruption problem
2. Application running without any problem after all the setting
3. No database problem

I believe this is what a basic requirement and should be provided by a hosting company and this is very important to us.

Trust me, never try your luck in http://www.internet-webhosting.com/
Some others review that tell the story:




Friday, March 27, 2009

Earth Hour



I'm in.  Are you?

Believe it,  it's simple. Switch off your light at local time 8:30pm on Saturday 28 March wherever you are in every corner of the world. Bring awareness to people around us on how much we love our earth.

Friday, March 13, 2009

Resize Image in Crystal Report 9 Visual Studio 2005

Well, many may think or looking for resize image in Crystal Report 9. Here is some hints and code that may help. Hopefully you can understand after go thru simple sample code.

1 pixel should be equal to 15 twips in Crystal Report.

int LogoWidth = 100;

      int LogoHeight = 80;

reportdocument.Load("abc.rpt");

reportdocument.SetDataSource(myDataTable);

reportdocument.Section2.ReportObjects["LogoImage1"].Width = LogoWidth * 15;

reportdocument.Section2.ReportObjects["LogoImage1"].Height = LogoHeight * 15;

CrystalReportViewer.ReportSource = reportdocument;

Sunday, March 1, 2009

JFolder::folder: Path is not a folder - AllVideos Reloaded in Joomla

In my local development machine, facing error after install AllVideos Reloaded in Joomla! 1.5.9

JFolder::folder: Path is not a folder
JFolder::files: Path is not a folder
JFolder::files: Path is not a folder

suspect is folder missing when AllVideos check on the playlist. The problem solve when i add a new folder manually to the folder videos to the playlist pointed folder. 

In my case, C:\xampp\htdocs\Joomla\images\stories\videos 

Hope this help you.

ps: it actually stated very clear that we need to create folder audio and videos in images/stories folder after the installation of AllVideos. It just that i didnt noticed. 


Sunday, February 15, 2009

Develop application using SQL Compact 3.5 SP1 with Visual Studio 2005

Can MS SQL Compact 3.5 SP1 work together with VS 2005? The answer is yes.

We are using Visual Studio 2005 (C#) and wish to create a window desktop application. After some consideration, the decision is for for MS SQL Compact 3.5 SP1. 

To enable me to work on MS SQL Compact 3.5 SP1:
  • Install MS SQL Compact 3.5 SP1 
  • Install MS SQL 2008 Express - to get SQL Server Management Studio to work with SQL Compact for table creation and scripting.
  • Add MS SQL Compact 3.5 SP1 engine to VS 2005 project
  • Connect to MS SQL Compact 3.5 SP1 engine in VS 2005 (C#) project

Install MS SQL Compact 3.5 SP1


The installation is easy and straightforward. I assume there will be no problem facing here.


Install MS SQL 2008 Express - to get SQL Server Management Studio to work with SQL Compact for table creation and scripting

In order to install MS SQL 2008 Express, you need to have below installed prio to that
  • Microsoft .NET Framework 3.5 Service Pack 1
  • Windows Installer 4.5
  • Windows PowerShell 1.0

After finish installation, you can connect to the MS SQL Compact 3.5 SP1 using SSMS. Open SSMS, choose Server type: "SQL Server Compact Edition" as shown below.


After that you can choose to create a new MS SQL Compact database or use the existing one as shown below:


After the connection, you can create table and etc. 

p/s: if you hit error "'' is not a valid login or you do not have permission" during installation, please refer to my previous post.


Add MS SQL Compact 3.5 SP1 engine to VS 2005 project

Open the project for the application, right click on Reference.



Browse on SQL Server Compact 3.5 sp1 engine (System.Data.SqlServerCe.dll) and add as reference. 

My location is in "C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Desktop\System.Data.SqlServerCe.dll"

Connect to MS SQL Compact 3.5 SP1 engine in VS 2005 (C#) project

remember to add reference to your C# code

using System.Data;
using System.Data.SqlServerCe;  // <-- Add this

SqlCeConnection _connection;

string fileName = "mycompactDB.sdf";
           string password = "AbCd1@3$5^7*";

           string connectionString = string.Format(
               "DataSource=\"{0}\"; Password='{1}'", fileName, password);

           _connection = new SqlCeConnection(connectionString);
           _connection.Open();

DONE! Hope this can help.

For other reading, can refer to 

SQL Server Compact 3.5
http://technet.microsoft.com/en-us/sqlserver/bb671088.aspx

SQL Server Compact 3.5 How-to Tutorials
http://msdn.microsoft.com/en-us/sqlserver/bb895908.aspx 


SQLCE 3.5 Database Tutorial
http://dotnetperls.com/Content/SQLCE-Database-Use.aspx

Dynamic Image in Crystal Report 9 Visual Studio 2005 - C#

I found many developers facing the same problem as i do - dynamic include image to crystal report with Visual Studio 2005 . This is how we solve our problem in C# when developing a desktop window application.

  1. In your xsd, create a colomn that does not exist in your dataset, example, [LogoImage], and set the datatype to “System.Byte[]”. You might find the datatype option only have “System.Byte”, you can manually type in “[]”.
  2. Add the following code in your form.

    private void AddImageColumn(DataTable objDataTable, string strFieldName)
    {
    try
    {
    DataColumn objDataColumn = new DataColumn(strFieldName,
    Type.GetType("System.Byte[]"));
    objDataTable.Columns.Add(objDataColumn);
    }
    catch (Exception ex)
    {
    //handler
    }
    }

    private void LoadImage(DataRow objDataRow, string strImageField, string FilePath)
    {
    try
    {
    FileStream fs = new FileStream(FilePath, System.IO.FileMode.Open,
    System.IO.FileAccess.Read);
    byte[] Image = new byte[fs.Length];
    fs.Read(Image, 0, Convert.ToInt32(fs.Length));
    fs.Close();
    objDataRow[strImageField] = Image;
    }
    catch (Exception ex)
    {
    //Handler
    }
    }

  3. After your getting your dataset from database and before bind to the report view, do this.

    AddImageColumn(myDataTable, "LogoImage");

    for (int index = 0; index < myDataTable.Rows.Count; index++)
    {
    if (myDataTable.Rows[index]["LogoLocation"].ToString() != "")
    {
    if(File.Exists(myDataTable.Rows[index]["LogoLocation"].ToString()))
    {
    LoadImage(myDataTable.Rows[index], "LogoImage",
    myDataTable.Rows[index]["LogoLocation"].ToString());
    }
    else
    {
    LoadImage(myDataTable.Rows[index], "LogoImage",
    "C:\\NoImage.jpg");
    }
    }
    else
    {
    LoadImage(myDataTable.Rows[index], "LogoImage", "C:\\NoImage.jpg");
    }
    }

  4. Then in your Crystal Report, just drag this column into the report.

Hope this solve your problem.

Monday, February 9, 2009

Installation SQL 2008 Express Error: '' is not a valid login or you do not have permission

This is a very strange error. I've received error message "'' is not a valid login or you do not have permission" when trying to install Microsoft SQL Server 2008 Express Edition in my Microsoft XP Pro SP3 Machine.

To know more on installation guide, please check Install and Configure SQL Server 2008 Express by CondorMan.

I've followed the steps and got error message "'' is not a valid login or you do not have permission." and print screen as below.



I have no idea why is this. I've tried few suggestion stated in some of the forum:


  1. I've tried to change my user name and try to install.
  2. Create a new user "sa" with strong password. Login to window using this account and do installation.
Both methods fail.

Finally, i try to rename my machine/computer name and try to install and the installation completed successfully.




Conclusion:
This may be a bug from microsoft but i'm not sure.

My scenario: computer name = my user account

My Solution: change computer name to != user account then do installation.

p/s: Change user account won't help.

Hope this can help you. Share your solution if you have different one.

Saturday, January 31, 2009

Visual Studio 2005 Crystal Reports deployment

Well, we have a visual studio 2005 windows application with crystal report and wish to deploy to customer machine. There are some basic files that needed to deploy to a normal xp home machine:
  • .NET Framework 2.0 - download from microsoft site
  • Project files - compile from Visual Studio 2005
  • Crystal reports merge module - discuss here

Here we will discuss how to create crystal reports merge module setup for deployment purposes.

Below are the steps :
  1. Generate a setup using setup wizard (either create a new project or add a new project to existing project), name it setup1.


  2. Right click in Setup1, select Add-> Merge Module. and open files listed below (by default, it will go to the correct directory which is C:\Program Files\Common Files\Merge Modules).


    Crystal_Database_Access2003.msm
    Crystal_Database_Access2003_enu.msm
    Crystal_Managed2003.msm
    Crystal_regwiz2003.msm



  3. now right click on Crystal_regwiz2003.msm , Click Properties. in properties window, Click on (MergeModuleProperties), in License Key property set license code of crystal report.

    This code can be obtained from Help menu -> About Microsoft Visual Studio, here u find a licence code for 'Crystal Reports'. copy this code and paste it in license key proparty.

  4. Almost done. Now build setup by Right click on Setup1 and Click on Build


  5. Copy the setup1.exe from you project output folder (normally is in Project's Debug or Release folder)

Install this exe during deployment. Done

More reference:

http://msdn.microsoft.com/en-us/library/ms225227(VS.80).aspx
http://msdn.microsoft.com/en-us/library/aa287924(VS.71).aspx
http://msdn.microsoft.com/en-us/library/aa288179(VS.71).aspx
http://msdn.microsoft.com/en-us/library/ms227409(VS.80).aspx


http://resources.businessobjects.com/support/additional_downloads/runtime.asp

Friday, January 23, 2009

A Happy, Healthy & Properous Year 2009

Well, everyone know it a tough time but we have to face and over it patiently and enjoy life at the same time. Happy Chinese New Year 2009.

新年安康, 心想事成!

Sunday, January 11, 2009

DSL 2640T wireless router Save and Reboot

There is an question that always ask by surfer on where can i find [Save and Reboot] button after i have change the port forwarding. There a lots of good article on port forwarding, hence, i wont discuss here. You can get a good one here http://www.portforward.com/english/routers/port_forwarding/Dlink/DSL-2640T/BitComet.htm

My concern here is where to find [Save and Reboot] button after all the setting.
Well, it's here
1. Click on Tools
2. Click on System
3. You can find the [Save and Reboot] button.






Done. Hope this help.