Posts

Select n random rows from SQL Server table

select top 10 percent * from [yourtable] order by newid() In response to the "pure trash" comment concerning large tables: you could do it like this to improve performance. select * from [yourtable] where [yourPk] in (select top 10 percent [yourPk] from [yourtable] order by newid()) The cost of this will be the key scan of values plus the join cost, which on a large table with a small percentage selection should be reasonable.

Verifying that a string contains only letters in C#

Only letters: Regex.IsMatch(input, @"^[a-zA-Z]+$"); Only letters and numbers: Regex.IsMatch(input, @"^[a-zA-Z0-9]+$"); Only letters, numbers and underscore: Regex.IsMatch(input, @"^[a-zA-Z0-9_]+$");

Reset Identity column after deleting record from table

DBCC CHECKIDENT can reseed (reset) the identity value of the table. For example, YourTable has 25 rows with 25 as last identity. If we want next record to have identity as 35 we need to run following T SQL script in Query Analyzer DBCC CHECKIDENT (yourtable, reseed, 34)

The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine

changed the application configuration to x86

get mouse click if inside a div or not

Use this Code : $("body > div").click(function() { if ($(this).attr("id") == "in_or_out") { // inside } else { // not inside } }); OR $(document).mouseup(function (e) { var container = $("YOUR CONTAINER SELECTOR"); if (container.has(e.target).length === 0) { container.hide(); } });

Unsafe JavaScript attempt to access frame with URL from frame with URL youtube

best solution to use youtube API : jQuery(document).ready(function() { var Vid = 'youtubeId'; var params = { allowScriptAccess: "always" }; var atts = { id: "myytplayer" }; swfobject.embedSWF("http://www.youtube.com/v/" + Vid + "?enablejsapi=1&playerapiid=ytplayer&version=3", "ytapiplayer", "320", "315", "8", null, null, params, atts); }); and add Div with ID "ytapiplayer"

HttpContext.Current.Session is null (Inside WebService)

[WebMethod(EnableSession = true)] public void SomeMethod() { ... code here }