Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

Wednesday, August 12, 2015

SQL Query by Date and Get 4 Nearest Record

Today here to play around with the SQL script and I try to revise my SQL script.

When come to date calculation, there is a build in function to calculate the date different. The function name is datediff(). How to use this function as it simple and you have to pass 2 value into this function and it will return the difference of day between the 2 value.

Example:
Value A: 2015-08-20; Value B: 2015-08-12 and the different of these2 day are 8

SELECT datediff('2015-08-20 00:00:00','2015-08-12') as 'dayto'

For today date there is a build in function too which is CURDATE()

In SQL if you want to get specific numbers of result return by SQL server you may using LIMITthen follow by the number of record.

Example to return 10 record.
Limit 10

Well the complete SQL script to get the top 4 nearest evetStartDate date from today as follow.

SELECT datediff(`evetStartDate`,CURDATE()) as 'dayto', `eventguid`,`eventName`,`evetStartDate`
FROM event
WHERE `evetStartDate` > NOW()
ORDER BY `evetStartDate` ASC
LIMIT 4"



Friday, August 7, 2015

LAMP Installation guide.

Finally finsh the development for the project. Now is the time to host the application on server. Due to cost saving concern, the application will host on a Linux node in VM. So LAMP is the choice we have decide to deploy and host the application. LAMP basically is the acronym of Linux, Apache, MySQL and PHP.

As previously I am using the XAMPP to start the PHP project development on Window. So now I have to deploy all the file into this new Linux node.

It is quite difficult to me as I have little knowledge on Linux Ubuntu and all have to use command to perform the installation. After go through the installation, I found that it quite simple but 1 thing is you have to know the command and mind your typed text else the command unable to execute.

Before begin the installation, make sure that you have connect to internet.

So start with install Apache. Below is the command to install the Apache. You may just copy paste the command.

sudo apt-get install apache2

after install Apache, no need to rush to start the service. Let continue with install Mysql with command below.

sudo apt-get install mysql-server

And now install the PHP.

sudo apt-get install php5 libapache2-mod-php5

Well, we have finish the installation for Apache, MySQL and PHP. So now we going to start the service.

sudo /etc/init.d/apache2 restart

after start the Apache service, you may use a browser to test the service. You may just type http://ipaddressofthehost/ on web browser to test it. It will respond a success page with it works!


And now the LAMP is success installed.


Friday, July 3, 2015

C# with MySQL Error

Recently doing a project using c# connect to MySql server. For sure the connectio is require connection driver so that I have download and install the latest version of MySql connector version (6.9.6).

This is the first time I am using c# to establish the connection with the server. Some how I hit error during the development. So now here I am to share the issues and solution. And I aware that this is MySql connector bugs.

Here the Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
 
Parser Error Message: Unable to connect to any of the specified MySQL hosts.
 
Source Error:
 

Line 283:    <siteMap>
Line 284:      <providers>
Line 285:        <add name="MySqlSiteMapProvider" type="MySql.Web.SiteMap.MySqlSiteMapProvider, MySql.Web, Version=6.9.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" applicationName="/" />
Line 286:      </providers>
Line 287:    </siteMap>
 
Source File: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config    Line: 285

There is many solution say that if can resolve by commnet out the particular line of config in machine.config file. You may try this soltion since there is some people mention they albe to resolve it by this. The path of machine.config file as below:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config 
<!--        <add name="MySqlSiteMapProvider" type="MySql.Web.SiteMap.MySqlSiteMapProvider, 

MySql.Web.v20, Version=6.9.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" 

connectionStringName="LocalMySqlServer" applicationName="/" /> -->
Reference: http://bugs.mysql.com/bug.php?id=74080&thanks=1&notify=71
But this solution not work for me.
So the next solution is to change the installation file by go to control panel -> program -> select MySql connector and select change. un-check the web provider and next all the way. Then the issues resolve. Hope it help.