Friday, June 12, 2015

XAMPP Port Issues

When I want to start a PHP development project, I use to face port issues during setup the XAMPP. You will face this issues where the Skype, VM Ware, or team viewer installed in your PC. The port is utilize by these few software so that your Apache service is unable to start.

This problem can easily solve by changing the port number if Apache. Click on the Config button on the XAMPP Control panel that same row with the Apache service. It will show a menu and select the Apache (https.conf) and it will open the config file with notepad. Using find/search (Ctrl +F) to find port number 80 and change it to a free port and the port you prefer. In my example below i change it to 8088

Snippet for port 80.

# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 8088

#
# Dynamic Shared Object (DSO) Support


And same goes to the secure port by choosing Apache (httpd-ssl.conf).


Snippet for SSL port number

# When we also provide SSL we have to listen to the
# standard HTTP port (see above) and to the HTTPS port
#
Listen 4443

##
##  SSL Global Context




After change your port number, restart the service and now you can access your site with provide the port number as below.

http://localhost:8088/testingSite/index.php

Bind Date Time in Gridview

During development, when try to bind data to a date time control in gridview, it successfully insert data in DB from the date time control. When try to retrieve back from DB and bind it to the date time control. There is always an empty field. So here my solution.

At aspx page, add a control to hold the value and make it visible to false.

<asp:Label ID="lblDate" Text='<%#Eval("PurchaseDate", "{0:dd MMM yyyy}") %>' runat="server" Visible="false" />

When the page load or any action trigger the reload of the gridview, the RowDataBound will bound the data row by row. So that we can use RowDataBound method to bind the data from label to the date time control.
Below is the code behind snippet.

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
 {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Label lblDate = (Label)e.Row.FindControl("lblDate");
                DateTimeControl dtDate = (DateTimeControl)e.Row.FindControl("PurchaseDate");

                if (!string.IsNullOrEmpty(lblDate.Text))
                {
                    dtDate.SelectedDate = Convert.ToDateTime(lblDate.Text);
                }
            }
}

Wednesday, May 13, 2015

Backup MS SQL Server

In order to ensure the database data is always goes well, so here I am to blog on how to perform the backup for MS SQL. For sure you may need to have access to the database server by using the SQL Server Management Studio. Select the database that you wish to backup and right click -> task -> backup


After the action, there will be a new window pop up and that the configuration page that how the backup to be done. There is few backup type available and in my case i would like to perform a full backup to backup the entire database. At the bottom there is a destination of the backup, if you wish to change it, you may need to remove it. For adding the custom backup destination, click on add and select the destination of the directory. 


There is more backup option available which locate at top right of the window. Select the Option, you may see the overwrite media configuration. You may able to replace the backup by select Overwrite all existing backup sets. So old the old backup file will be replace with the new backup.

After finish configure, it will start the backup process


Lastly, when the backup is finish, there will prompt a message.


Tuesday, April 28, 2015

Database is Suspect Mode

There is a time the electric blackout in my place and cause the database is unable to open. There is a (Suspect) after the database name as show as screen shot below. This know as Suspect Mode.



This issues may cause by:
  • There is not enough space available for the SQL Server to recover the database during startup.
  • The database cannot be opened due to inaccessible files or insufficient memory or disk space.
  • The database files are being held by operating system, third party backup software etc.
  • There was an unexpected SQL Server Shutdown, power failure or a hardware failure.


In order to resolve this problem, recovering is needed to access again the database. So first of all you may need a database administrator account login the MS SQL Management and click on new query button. And start the script as below:

EXEC sp_resetstatus [YourDatabaseName];
ALTER DATABASE [YourDatabaseName] SET EMERGENCY
DBCC checkdb([YourDatabaseName])
ALTER DATABASE [YourDatabaseName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ([YourDatabaseName], REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE [YourDatabaseName] SET MULTI_USER


Replace YourDatabaseName with your database name. In my example will be as follow.


EXEC sp_resetstatus [test_dr];
ALTER DATABASE [test_dr] SET EMERGENCY
DBCC checkdb([test_dr])
ALTER DATABASE [test_dr] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ([test_dr], REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE [test_dr] SET MULTI_USER

Once you have done the script, click on execute query at the top. If for the first time is fail, double click again the make the script run. Then refresh your Object explorer and the (Suspect) will get rid and able to access the database again.

Microsoft SQL Server Error 926

In my development life, there is many issues coming up to resists you in development. Database is one of it,  as today I face this issue below. This error able me to start the MS SQL Management Studio but unable to see any one of the db on it. After some time of troubleshooting, finally get this issues resolve.


In order to resolve this issues, you may need another working database. Copy the MSDBDATA.mdf and MSDBLOG.ldf  from another environment machine.

By default, the files directory  will some where around here. (If you have custom path, please check your own database setting.)

C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA

In order to copy and replace both of the files, you need to stop your SQL Server Service  then only able to copy and replace both of the file.

Please make sure you make a backup before you replace the file as a safe keeping for just in-case purpose.

Once you replace the working MSDBDATA and MSDBLOG files, start the SQL Server service again.

Tuesday, April 14, 2015

My RAID 0 PC

I have 2 extra hard drive that not in use and think of increase the storage size of the PC. So that i have made a decision that to setup hard drive as RAID 0. Why i chose RAID 0 because it able to provide batter performance compare with setup hard drive as secondary hard drive. In the same time, RAID  0 also able provide redundancy which use another hard drive as recover medium.

For gaming user or hard disk resource hungry application may consider this choice without compromising the performance and space.

Below is the performance chart during copy of large file from a USB 3.0 external hard disk to local disk (raid volume). 



So make sure using the latest version of RAID driver as it give slightly increase of performance too.

Tuesday, April 7, 2015

Promoting Window Server 2012 as Domain Controller

After you have done installation of the Active Directory service on the server, you may need to so call "activate" the service and do some configuration on the server to work accordingly. This process know as DC promo.

In the top right corner, a warning label will now appear next to the task details icon. Click on this icon and select Promote this server to a domain controller. As screenshot below.


Let do a testing domain with the name of "contoso.local". For new domain controller, you may need to select Add a new forest, and you have to provide the domain name.


Specify the Forest functional Level, Domain Functional Level, whether or not it should be a DNS Server and also the DSRM administrator password. As you can see, it has selected the Global Catalog option by default and you cannot deselect it. The reason for this is that is the very first DC of the AD forest and at least one needs to be a Global Catalog .


After click on next, it will prompt a DNS delegation warning, you just have to click ok and proceed with next step which is NetBIOS name. The NetBIOS name will auto assigned and you just need to click next.


All the related folder Active Directory database, log files and SYSVOL data was left at their default locations. I will remain the same place and just click on next.


After that it will provide you a list of summary of setup as screenshot below.


Windows will perform a prerequisites check. If the user account used to promote the server does not have sufficient privileges (Schema Admin or Enterprise admin), then the installation will not be able to be completed. Either log onto another account that has the correct permissions or grant those permissions to the desired user and start over from the beginning of the promotion wizard. 


When you click Install, DNS and the GPMC are installed automatically.


After the promotion of the server to a DC finished server restart automatically. Congratulation, you have successfully install and config the domain controller.