I recently had occasion to access the contents of a cookie stored on the clients computer using Javascript. I found the following javascript function very handy. I wander if something similar is built into javascript:
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else {
begin += 2;
}
var end = document.cookie.indexOf(";", begin);
if (end == -1) {
end = dc.length;
}
return unescape(dc.substring(begin + prefix.length, end));
}
Monday, July 30, 2007
Stylesheet Link
Probably the easiest method of adding a link to an additional style sheet in code is this:
Page.Header.Controls.Add(new StylesheetLink("/css/mystyle.css"));
Page.Header.Controls.Add(new StylesheetLink("/css/mystyle.css"));
Thursday, July 26, 2007
A Look at GUIDs
Summary:
Not many people enjoy using Globally Unique Identifiers (GUIDs), partly because they are cumbersome to type and work with for humans. However they fill a need and can provide some interesting benefits. SQL Server expert Andy Warren takes us through what a GUID is and how you can use it easily in your code.
Not many people enjoy using Globally Unique Identifiers (GUIDs), partly because they are cumbersome to type and work with for humans. However they fill a need and can provide some interesting benefits. SQL Server expert Andy Warren takes us through what a GUID is and how you can use it easily in your code.
The difference between Where and Group By
"The WHERE clause (# 3) evaluates data before the GROUP BY clause does. When you want to limit data after it's grouped, use HAVING. Often, the result will be the same whether you use WHERE or HAVING, but it's important to remember that the clauses are not interchangeable. Here's a good guideline to follow when you're in doubt: Use WHERE to filter records; use HAVING to filter groups.
Usually, you'll use HAVING to evaluate a group using an aggregate. For instance, the following statement returns a unique list of ZIP codes, but the list might not include every ZIP code in the underlying data source: SELECT ZIP, Count(ZIP) AS CustomersByZIP FROM Customers GROUP BY ZIP HAVING Count(ZIP) = 1
Only those groups with just one customer make it to the results. "
Usually, you'll use HAVING to evaluate a group using an aggregate. For instance, the following statement returns a unique list of ZIP codes, but the list might not include every ZIP code in the underlying data source: SELECT ZIP, Count(ZIP) AS CustomersByZIP FROM Customers GROUP BY ZIP HAVING Count(ZIP) = 1
Only those groups with just one customer make it to the results. "
What Query Plans are in SQL Server's Memory?
"SQL Server memory is primarily used to store data (buffer) and query plans (procedure cache). In this article I'll show how much memory is allocated to the procedure cache (RAM). I'll explain how to determine what plans are in the cache and how often they're used.
SQL Server stores the procedure cache in 8KB data pages. You can use the dynamic management view sys.dm_os_memory_cache_counters to provide a summary of how the cache is allocated using this query"
SELECT TOP 6
LEFT([name], 20) as [name],
LEFT([type], 20) as [type],
[single_pages_kb] + [multi_pages_kb] AS cache_kb,
[entries_count]
FROM sys.dm_os_memory_cache_counters
Order By single_pages_kb + multi_pages_kb DESC
SQL Server stores the procedure cache in 8KB data pages. You can use the dynamic management view sys.dm_os_memory_cache_counters to provide a summary of how the cache is allocated using this query"
SELECT TOP 6
LEFT([name], 20) as [name],
LEFT([type], 20) as [type],
[single_pages_kb] + [multi_pages_kb] AS cache_kb,
[entries_count]
FROM sys.dm_os_memory_cache_counters
Order By single_pages_kb + multi_pages_kb DESC
What Data is in SQL Server's Memory?
"SQL Server memory is primarily used to store data (buffer) and query plans (cache). In this article I'll show how much memory is allocated to the data buffer (or RAM). I'll explain how to determine what tables and indexes are in the buffer memory of your server.
SQL Server stores its data in 8KB data pages. As these pages are read off disk they are stored in memory. This is referred to as buffer memory. A list of all the data pages in memory is stored in the dynamic management view sys.dm_os_buffer_descriptors."
SQL Server stores its data in 8KB data pages. As these pages are read off disk they are stored in memory. This is referred to as buffer memory. A list of all the data pages in memory is stored in the dynamic management view sys.dm_os_buffer_descriptors."
Wednesday, July 25, 2007
Some Tips and Tricks for using an ObjectDataSource with a Gridview
Subscribe to:
Posts (Atom)