Advertisements

AngularJS: Get selected Text and Value of HTML Select DropDownList using ng-change


The below HTML Markup consists of an HTML DIV to which ng-app and ng-controller AngularJS directives have been assigned.

The HTML DIV consists of an HTML Select DropDownList which will be populated from JSON array using ng-options directive.

The HTML Select DropDownList has been assigned ng-change directive. When an option is selected in HTML Select DropDownList then the GetValue function of the Controller gets called.
Inside the function, first the selected Value is fetched from the ng-model attribute and the selected Text is fetched from the JSON array using jQuery grep function.
Finally the selected Text and Value is displayed using JavaScript alert message box.

2016-06-21_1554

Advertisements

Age calculation in mysql Select query


Following is the way to calculate age based on date in mysql select query

SELECT name, 
birth, 
CURDATE(), 
TIMESTAMPDIFF(YEAR,birth,CURDATE()) AS age 
FROM 
TableName; 

+----------+------------+------------+------+ 
| name | birth | CURDATE() | age | 
+----------+------------+------------+------+ 
| Fluffy | 1993-02-04 | 2003-08-19 | 10 | 
| Claws | 1994-03-17 | 2003-08-19 | 9 |
| Buffy | 1989-05-13 | 2003-08-19 | 14 | 
| Fang | 1990-08-27 | 2003-08-19 | 12 | 
| Bowser | 1989-08-31 | 2003-08-19 | 13 | 
| Chirpy | 1998-09-11 | 2003-08-19 | 4 | 
| Whistler | 1997-12-09 | 2003-08-19 | 5 | 
| Slim | 1996-04-29 | 2003-08-19 | 7 | 
| Puffball | 1999-03-30 | 2003-08-19 | 4 | 

+----------+------------+------------+------+ 
Hope this is helpful !


Function to find dates in current week in mysql


MySQL YEARWEEK() returns year and week number for a given date.

Syntax: YEARWEEK(date_value,Mode)

Parameters or Arguments

date_value
A date or datetime value from which to extract the year and week.
mode
Optional. It is used to specify what day the week starts on. It can be one of the following:

mode Explanation Week Value
0 First day of the week is Sunday 0-53
1 First day of the week is Monday and the first week has more than 3 days 0-53
2 First day of the week is Sunday 1-53
3 First day of the week is Monday and the first week has more than 3 days 1-53
4 First day of the week is Sunday and the first week has more than 3 days 0-53
5 First day of the week is Monday 0-53
6 First day of the week is Sunday and the first week has more than 3 days 1-53
7 First day of the week is Monday 1-53

Example : select YEARWEEK(now());

The following statement will return the year and week number of the date 2016-05-19.

SELECT YEARWEEK(‘2016-05-19’);

 

mysql-yearweek-function

 

Hope this help!

HEX Color Code Converter / Chooser

March 29, 2016 Leave a comment

Unable to launch the ASP.NET Development server because port ‘1900’ is in use


The Problem

You are coding away, Visual Studio locks up for one of it’s many reasons, and reopen your project and run it again. You then get the “Unable to launch the visual studio development server because port 9452 is in use” error

The Cause

When Visual Studio crashed, the Web Server did not, so basically it thinks you are trying to run two instances at the same time, which is not allowed.

The Solution

Open up the process manager, go to the Processes tab, and select “WebDev.WebServer40.exe” and click “End Process”. Then try running your project again. Visual Studio will now start the project fresh and the problem should go away.

1

Or try this

2jpg

 

Hope it helps !

null oid not supported Telerik OpenAccess

February 18, 2016 Leave a comment

Error : Null oid not supported 

Stack trace
[ArgumentException: null oid not supported]
at Telerik.OpenAccess.SPI.Backends.ThrowException(Exception e)
at OpenAccessRuntime.ExceptionWrapper.Throw()
at OpenAccessRuntime.common.StatesReturned.addImp(OID oid, State state, Boolean directFlag)
at OpenAccessRuntime.common.StatesReturned.add(OID key, State value_Renamed)
at OpenAccessRuntime.Relational.RelationalQueryResult.fetchManagedTypes(ApplicationContext context, Int32 fetchAmount, QueryResultContainer results)
at OpenAccessRuntime.Relational.RelationalQueryResult.fetchNextResultBatch(ApplicationContext context, QueryResultContainer results, Int32 fetchAmount)

 

Reason :

Its because of the there is an object where the id (Primary key) field contains a null.

if there is an entity having two fields set as Identity field. and one of the fields is purely unique (set a Primary Key in DB)  where as the other one is not so this kind of error raised by Telerik ORM.

Solution:

Telerik ORM is not supporting  ‘null’ values as part of the identity. Each member that makes up the identity of a class must have a non-null value. There is no workaround either to this problem.

Hope this help !

Order by Date Descending issue (Linq)

February 12, 2016 Leave a comment

Issue :

 Dim list As List(Of Eventlist) = (From d In EventList
 Order By d.Status Descending, d.StartDate Descending, 
 Select d).ToList()

It gives me the date ordered by month and day, but doesn’t take year into consideration. for example:

12/31/2009 
12/31/2008
12/30/2009
12/29/2009

Needs to be more like:

12/31/2009
12/30/2009
12/29/2009
12/28/2009

Solution :

 Dim list As List(Of Eventlist) = (From d In EventList
 Order By d.Status Descending, Year(d.StartDate) Descending, Month(d.StartDate) Descending, Day(d.StartDate) Descending
 Select d).ToList()


Hope it helps !