Get Max value for selected column of each row in Linq

 

https://forums.asp.net/t/2071927.aspx?Get+Max+value+for+selected+column+of+each+row+in+Linq

https://stackoverflow.com/questions/6864311/the-cast-to-value-type-int32-failed-because-the-materialized-value-is-null

https://forums.asp.net/t/1637613.aspx?LINQ+for+inserting+max+value+1

 

 

Advertisements

Add maxlength on textArea using jQuery

The Low Down

The maxlength attribute limits the number of characters that an <input> or<textarea> can accept. The maxlength attribute on textarea is new in HTML5.

  • Works for GUI-less inputs like text, email, url, search, tel and password.
  • Upon data entry, browsers will not permit the user to enter more than the characters defined by the value of the maxlength attribute: cutting off the text as-you-type and truncating pasted text. This can lead to bad user experience.
  • maxlength does not limit placeholder length.
  • If a preset value is included with a value that has more characters than the allowed length, a validation error will not be thrown. However, if that preset value is edited, yet is still longer than the allowed length, the element will become invalid, matching the :invalid pseudoclass selector, and will be prevented from being submitted in both Opera and IE10+, which both display the tooLong validity error message.
  • IE 9 reported support on both inputs and textareas but only works on inputs.

Source: https://www.wufoo.com/html5/attributes/03-maxlength.html

 

HTML 5
The textArea “maxlength” attribute is supported in HTML 5, the problem is not all browsers support HTML 5, especially, the old IE.

 

jQuery Example

A jQuery example to implement the “maxlength” effect on a textarea field.

<html>
<head>
<script language="javascript" type="text/javascript"
	src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
<script language="javascript" type="text/javascript">

    $(document).ready( function () {

	maxLength = $("textarea#comment").attr("maxlength");
        $("textarea#comment").after("
" + maxLength + " remaining
"
); $("textarea#comment").bind("keyup change", function(){checkMaxLength(this.id, maxLength); } ) }); function checkMaxLength(textareaID, maxLength){ currentLengthInTextarea = $("#"+textareaID).val().length; $(remainingLengthTempId).text(parseInt(maxLength) - parseInt(currentLengthInTextarea)); if (currentLengthInTextarea > (maxLength)) { // Trim the field current length over the maxlength. $("textarea#comment").val($("textarea#comment").val().slice(0, maxLength)); $(remainingLengthTempId).text(0); } }
</script> </head> <body> <h1>TextArea maxlength with jQuery</h1> <textarea id="comment" maxlength="10" rows="10" cols="60" ></textarea> </body> </html>

 

Source: http://www.mkyong.com/jquery/add-maxlength-on-textarea-using-jquery/

 

 

 

 

 

Difference between Identity and Sequence in SQL Server

S.No Identity Sequence
1 Dependant on table. Independent from table.
2 Identity is a property in a table.

Example :

CREATE TABLE Table
test_Identity

(

[ID] int Identity (1,1),

[Product Name] varchar(50)

)

 

 

Sequence is an object.

Example :

CREATE SEQUENCE [dbo].[Sequence_ID]

AS [int]

START WITH 1

INCREMENT BY 1

MINVALUE 1

MAXVALUE 1000

NO CYCLE

NO CACHE

3 If you need a new ID from an identity column you need to
insert and then get new ID.

Example :

Insert into [test_Identity] Values (‘SQL Server’)

GO

SELECT @@IDENTITY AS ‘Identity’

–OR

Select SCOPE_IDENTITY() AS‘Identity’

In the sequence, you do not need to insert new ID, you can view the new ID directly.

Example :

SELECT NEXT VALUE
FOR dbo.[Sequence_ID]

 

 

4 You cannot perform a cycle in identity column. Meaning, you cannot restart the counter after a
particular interval.

 

In the sequence, you can simply add one property to make it a cycle.

Example :

ALTER SEQUENCE [dbo].[Sequence_ID]

CYCLE;

5 You cannot cache Identity column property. Sequence can be easily cached by just setting cache property of
sequence. It also improves the performance.

Example :

ALTER SEQUENCE [dbo].[Sequence_ID]

CACHE 3;

6 You cannot remove the identity column from the table directly. The sequence is not table dependent so you can easily remove it

Example :

Create table dbo.[test_Sequence]

(

[ID] int,

[Product Name] varchar(50)

)

GO

–First Insert With Sequence object

INSERT INTO dbo.test_Sequence ([ID],[Product Name]) VALUES (NEXT VALUEFOR [Ticket] , ‘MICROSOFT SQL SERVER 2008’)

GO

–Second Insert without Sequence

INSERT INTO dbo.test_Sequence ([ID],[Product Name]) VALUES (2 ,‘MICROSOFT SQL SERVER 2012’)

7 You cannot define the maximum value in identity column it is
based on the data type limit.
Here you can set up its maximum value.

 

Example :

ALTER SEQUENCE [dbo].[Sequence_ID]

MAXVALUE 2000;

8 You can reseed it but cannot change the step size.

Example :

DBCC CHECKIDENT (test_Identity,RESEED, 4)

 

You can reseed as well as change the step size.

Example :

ALTER SEQUENCE [dbo].[Sequence_ID]

RESTART WITH 7

INCREMENT BY 2;

9 You cannot generate range from identity. You can generate a range of sequence
values from a sequence object with the help of sp_sequence_get_range.

 

Source: https://raresql.com/2012/05/01/difference-between-identity-and-sequence/

 

SSMS Ctrl+R Show/Hide Results Pane shortcut is missing on menu

To work around this issue, reset the default keyboard mapping scheme. To do this, follow these steps:

  1. Open SQL Server Management Studio.
  2. On the menu bar, click Tools, and then click Options.
  3. In the tree-view pane on the left side of the dialog box, click Keyboard.
  4. Click Reset to reset the default keyboard mapping scheme.
  5. In the dialog box that appears, click Yes.
  6. Click OK.

https://support.microsoft.com/en-us/help/2860024/you-cannot-toggle-the-results-pane-in-sql-server-management-studio

https://connect.microsoft.com/SQLServer/feedback/details/679651/ssms-ctrl-r-show-hide-results-pane-shortcut-is-missing-on-menu-and-as-functionality

 

IIS 7.5 – uploadReadAheadSize

IIS 7.5 – uploadReadAheadSize

A developer recently reported a problem that when a customer attempted to upload an attachment, they would sometime receive the error:

The page was not displayed because the request entity is too large.

In our case it did not include an error number, but it will sometimes include the error number:

HTTPS 413

The fix for us is listed below:

How to set the uploadReadAheadSize in IIS 7.5

  1. Launch “Internet Information Services (IIS) Manager”
  2. Expand the Server field
  3. Expand Sites
  4. Select the site you want to make the modification for.
  5. In the Features section, double click “Configuration Editor”
  6. Under “Section” select: system.webServer>serverRuntime
  7. Modify the “uploadReadAheadSize” section
  8. Click Apply
– Note that the value is in BYTES
Source: http://tips4sysadmins.blogspot.com/2012/12/iis-75-uploadreadaheadsize.html