| Subcribe via RSS

HowTo : Crystal report XI with Data source

April 21st, 2007 | No Comments | Posted in Applications, Crystal report

I don’t know everyone used to encounter with this problem, but I was. When I using crystal report connected with SQLServer 2005 using Microsoft OLE DB connector. I cannot use “localhost\sqlexpress” as a Data Source Name, I don’t know why? but I can use “localhost\sqlexpress” when I using sqlcmd to connect database. So my solution is using “.\sqlexpress” instead “localhost”. At least it’s work for me.

HowTo : C# change DateTime format programmatically

April 19th, 2007 | No Comments | Posted in .NET, Programming

When you use Datetime. Now in c#, it’ll give u a datetime as same as in your computer configured. If you want to change it by programmatically. use the following code.

using System.Globalization;

private DateTime dt = DateTime.Now;
private DateTimeFormatInfo dfi = new DateTimeFormatInfo();
private CultureInfo ci = new CultureInfo(“th-TH”); // Change where is you culture do you want

Console.WriteLine(dt.ToString(“d”,ci));

Reference : http://msdn2.microsoft.com/en-us/library/az4se3k1(VS.71).aspx

FIX : Windows XP Fix svchost.exe 100% CPU usage

April 17th, 2007 | No Comments | Posted in Windows

Does anybody encounters problems, svchost.exe consume most of CPU. I don’t know does anybody has the same problem with me?, but my problem is about Windows Update. CPU utilization would hit 100% when windows xp want to updating something, it take so much time. This is how I fix about it.

http://www.daniweb.com/techtalkforums/thread75130.html

You can just turn it off but If you turned off you cannot update via website either.

You can use this program to watch what process consume most of your CPU. You can see every processes and every application.
http://www.microsoft.com/technet/sysinternals/utilities/ProcessExplorer.msp

HowTo : SQLServer 2005 : Exclusive access could not be obtained because the database is in use

April 11th, 2007 | No Comments | Posted in Database, Knowledges, Programming, SQL Server, Techniques

“Exclusive access could not be obtained because the database is in use”

I got stuck with this error couple days, so mad. I found this solution in this topic, it works fine for me, anyway here’s the solution

When you want to restore database in SQLServer you must use ‘master’ database run command. If it work fine, so never mind, but if you got stuck in this kind of errors again. This solution may help you.

Use this sql to drop connections

ALTER DATABASE databasename SET SINGLE_USER WITH ROLLBACK IMMEDIATE

And follow with restore sql

RESTORE DATABASE databasename FROM …

The last follow with allow connections

ALTER DATABASE databasename SET MULTI_USER

Tutorial : Backup and Restore SQLExpress with C#

April 10th, 2007 | No Comments | Posted in .NET, Database, Programming, SQL Server

SQLExpress 2005 will use SMO to manage database, it ship drom DMO from older version (2000). In this topic I’ll talk about SMO.

If you are using SQLServer Express Edition must read this topic

http://www.codeproject.com/useritems/SMODemo.asp This is example application with SMO.

http://www.sqldbatips.com/showarticle.asp?ID=34 Another example application.

However, I’ll present another way to use Backup and Restore database via C#, not using SMO. We’re using StoreProcedure. Sound wired aha, but I just find another ways HaHa.

CREATE PROCEDURE BackUpDatabase
@name varchar(max)
AS
BACKUP DATABASE databasename TO @name
WITH FORMAT, NAME = ‘Full Database Backup’, SKIP, NOREWIND, NOUNLOAD, STATS = 10

This store procedure can backup database in the same way, but maybe not easy to use it. anyway I prefer to use SMO to backup and restore database, much more easier.

In c#

myConnection = new ….
SqlCommand comadd = new SqlCommand(“BackUpDatabase”,myConnection);
comadd.CommandType = CommandType.StoredProcedure;

SqlParameter param1 = new SqlParameter(“@name”, name);
comadd.Parameters.Add(param1);

try
{
comadd.ExecuteNonQuery();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
finally
{
myConnection.Close();
}

Or you can use direct SQL direct to SqlCommand neither, It’s work fine.

HowTo : Set loopback on Router (ZyXeL)

April 6th, 2007 | No Comments | Posted in Techniques

Everyone, used to use Dynamic DNS Server, which is use your router and ADSL line setting your PC like a Server.

This topic would all about If you set you PC as a SERVER, but when you access its webpage in your server. You will get “Weppage not found”, because your router will browse in the Internet first, it cannot loopback on itself. you must set “Loopback Command” on a router.

Q: Why can not I access the LAN server from LAN host using its domain name?
A: This is because when NAT is enabled in the NAT router, the domain

   name will be resolved to the WAN IP of the NAT router. This

   causes the traffic stop at the WAN side of the NAT router when the

   request is sent from the host to the internal server. And never

   arrive at the server.

Therefore, if you try to access this server from LAN side also

   using its domain name, we provide an enhanced solution (not for

   all models) to achieve this.

You need to do two settings:

1. Go to Menu 24.8 and type the following CI command

ras > ip nat loopback on

2. Configure Port Forwarding in menu 15.1 by entering the server

      IP and port number.

Otherwise, you can only use the IP address to access the internal

server from any LAN host. While only the remote users can use the

domain name instead.