My brother in law, Dougal has an interesting post about typefaces for webpages. ( http://dougal.gunters.org/blog/2007/07/05/typography-design-patterns-for-the-web ). You may have seen color charts for web page design, where it lists a primary color and other colors that compliment it. What Dougal is looking for is a similar chart for fonts. Anyone know of anything? If so post a comment on his blog or mine (or both!) and let us know.
Arcane Thanks
Just wanted to say thanks to everyone at BSDA tonight. I had a lot of fun, and the audience was very attentive and engaged. Even the “parking lot” session afterward was a lot of fun, some great questions and give and take. All in all it was not only a great experience but a lot of fun. Thanks guys!
Arcane
Arcane Talks
On Thursday July 12th I’ll be speaking at the Birmingham Software Developers Association (BSDA). You can get directions from the club’s website, http://www.bsda.info/ .
I’ll be speaking on the subject of SQL Server Compact Edition. It’s been a while since I blogged about this, so I thought I’d provide a few links for quick reference.
As promised, here is a link to the Power Point presentation (in PDF format) I used during the presentation:
SSCE presentation for BSDA user group
My very first post was back in January 2007:
My next series of posts began on April 10th, and described how to create databases using the various tools available to you.
The complete C# and VB.Net code samples were posted April 13th, 2007:
And finally, the series of posts I mentioned on system Views started with this post on April 16th, 2007:
If you want to see all of my SSCE posts, simply click the SQL Server Compact Edition tag over in the categories area, or use this link:
https://arcanecode.wordpress.com/tag/sql-server-compact-edition/
Please note each of these links is a starting point, be sure to read the blog for the next few days after each link in order to get the full story.
And now a question, I’m working up material for a new presentation. Debating between SQL Server 2005 Full Text Searching and SQL Server Integration Services. Any opinions?
Eventually I’ll do both, but would like to do the first one based on feedback. Even if you can’t attend please post a comment and let me know where your interests lie.
Arcane Portable Passwords
After a long time searching, I finally found a password manager I like. I’ve looked at quite a few, but for whatever reason never seemed to find one that suited me. Today I finally found KeePass and am happy.
KeePass ( http://keepass.info/ ) is a free, open source password manager. It has the same basic functionality that most password managers have, but laid out in such a manner that to me is easy to use. It will generate a complex password for you, or you can enter your own. It even has a meter, which measures the strength of your password.
Be warned I had some issues with the installer version of KeePass under Vista. However, it also has a standalone no-install version which you can download and use, which is what I did. It works like a champ under Vista.
It also has a version (http://portableapps.com/apps/utilities/keepass_portable ) that integrates nicely with Portable Apps ( http://portableapps.com/ ). In case you are not familiar with Portable Apps, it’s a suite of tools that don’t require installation.
The idea behind portable apps is you can place all of them on a USB thumb drive or external USB Hard drive. Then no matter what machine you plug it into, all off the apps and settings go with you. Nothing is stored on the host PC.
There are versions of FireFox, OpenOffice, GIMP (the paint program), and of course KeePass. Much more too, so take a look. Great for someone who travels a lot and just needs a few simple apps on the road.
Arcane Thoughts: Privacy in 2054
You might not have known it from the blog but I took last week off. Vacation! I actually took a little time away from the computer and caught up on some movie watching (made some good finds in the five dollar bin at my local big box discount store).
One movie I saw was Minority Report, based on the Phillip K. Dick story. In short, it’s the year 2054, and there are some precognitive people who can see murders before they happen, which allows the hero to stop the murder before it happens.
Whats interesting though is the optical scanners that blanket the city. As the hero walks down a street, optical scanners are constantly scanning his eyes. Wall mounted billboards greet him by name, asking him if he’d like to buy more of whatever it was they were selling. One even asks how he’s enjoying a previous purchase, mentioning they have a sale or something.
In addition the scanners track his movements as he moves through the city. They control admission to buildings, his purchases, etc.
Even though they movie takes place in the year 2054, I suspect we’re a lot closer than 47 years from this sort of targeted marketing. Everytime I go to Amazon, it has a list of recommendations based on my past purchases. Google gives you targeted advertising based on your current search.
Is this a good thing? I can’t say I’ve decided yet. On one hand I do appreciate having relavent ads. On the other hand, I don’t know that I’m comfortable with not only being tracked, but who might have access to that data. For example, perhaps I don’t want my insurance company to know I’m doing MSN Live searches for home remedies for back pain.
It’s not just the web that’s tracking you. How much info is being logged from just using your software? I have quite a bit of software that calls home looking for updates on a regular basis. At the back of my mind I often wonder what other info is getting passed back and forth.
Cranky Geeks latest episode (#71 as I write this, http://www.crankygeeks.com/2007/07/episode_71_how_vulnerable_are.php ) has a very interesting discussion on the entire topic as I write this.
So am I worried for nothing? Should I care if Amazon (or anyone else) knows I like books about .Net? Are we doomed as a society to “big brother”? Let me know your thoughts.
Happy Birthday Anna
Arcane Tidbits
Today I thought I’d cover a few items that I found interesting, but were not in and of themselves enough info for an extensive blog post. I call these Arcane Tidbits.
First up is an interesting new Trojan horse that is attacking computers. When you reboot the computer, something pops up that looks alarmingly like the Microsoft Windows Activation screen. It tells you another user has activated your copy of Windows, and demands you enter credit card info as a way to validate your identity, of course reassuring you that you won’t be charged. If you fail to do so it shuts down your PC. PC Magazine has an interesting writeup as well as a link on how to remove this pest at http://www.pcmag.com/article2/0,1895,2147608,00.asp .
Another interesting story from PC Magazine, the first known spam sent out as a PDF file is now in circulation. Read more about it at http://blogs.pcmag.com/securitywatch/2007/07/more_pdf_spam.php . To quote Patrick Norton (http://dl.tv/ ) “Remember kids, never ever ever open attachments from people you don’t know, and sometimes even from people you do.”
If you’ve been working in the .Net space for a bit, you’ve probably heard of the new Microsoft Cardspace that is part of .Net 3.0. However, you may be looking for a good basic intro to give to your boss or non-programming friends like system administrators to help them understand it. In episode 98 of Security Now, Steve Gibson gives a nice basic overview of what Cardspace is and how it works.
You can this episode at http://www.twit.tv/sn98 . Steve does get a bit technical, so I don’t know I’d suggest it for your dad (unless your dad is a former CIO like mine) but for your boss, DBAs, or System Admins it’s a good intro on what it is and how it works without getting into the programming. You might want to listen to show 95 (http://www.twit.tv/sn95 ) on OpenID first, as OpenID and Cardspace go hand in hand.
Next a bit of a personal note, I feel like a kid in a Web 2.0 candy store lately. You see, up until this week I’ve been using Hughes DirecWay to get my internet via Satellite. The speed was slow, about 700k down, but better than dial up. The downside is their FAP, or Fair Access Policy. Now I was spending nearly 90 bucks a month for their Professional Level service. Under that plan, I would get FAPped if I downloaded “too much”.
And how much is too much? Good question, I tried to find that out myself and was met with evasive technical answers. The best I could determine, based upon the elusive answers given to me by several tech support personnel, was somewhere around 50 megabytes an hour. Yes, you are reading that correct, 50 megabytes an hour, or about 1 podcast.
And what happened if I downloaded to much? Well I got FAPped as they call it, my bandwidth was choked back to a speed so slow it made dial up attractive. And forget doing VPN on it, it won’t work.
In order to get the speed out of the satellite, Hughes compresses the packets before they go up and down to the satellite via the dish. With VPN however all traffic is encrypted, so it can’t see the packet to compress it. Oh, the sales people don’t mention this, and one even told me it “should work” and I have to admit that once, just once, I actually made a VPN connection to the office. It was so slow though I had time to drive to the office to see the results of a single keypress.
Well happy days are here as AT&T ran DSL to my house last week. The installer could not have been nicer and more professional, and they even called a few days later to follow up and make sure everything was still working. I admit I was a bit dubious when AT&T bought BellSouth, but so far they look like they really have their act together.
My rather long winded point is I now have an 8 megabit connection to the net, with no limitations on bandwidth. No more FAPping! No more latency! No more 90 bucks a month for a service I’m not allowed to use! I’m now free to go explore all the cool Web 2.0 stuff like Skype, YouTube, and more. I’m sure I’ll be blogging about my experiences, but if you know of some cool high bandwidth technologies I can go play with drop a comment and let me know.
And finally, my local Discovery store is closing (sniffle). True there’s still the online store, but it was a lot of fun to go in and browse. I picked up two books I’ve had my eye on for a while at a deep discount. One is Mythbusters: Don’t Try This At Home Unless We Tell You To. It’s a book of experiments you can do with your kids, I intend to give it to my daughters and we can have some fun with it.
The second book is also about Mythbusters, and talks about the founding of the show and covers the stories behind 30 of their most popular myths. I’ve already looked through the first chapter, this looks to be a fun read, and with discounts I bought both books for a mere 20 bucks. You might want to check your local Discovery store as well.
And there you go a few little tidbits for your reading pleasure.
Standard Disclaimer: I receive no considerations financial or otherwise from any of the business or products mentioned in today’s post, and being a geek think the Mythbusters are really really cool.
Happy Birthday U.S.A.
Today is the 4th of July, and in the U.S.A. a national holiday. I’ll be taking the day off, celebrating my country’s birthday with barbeque, fireworks and special events.
Here in Alabama we have a great place called American Village ( http://americanvillage.org/index.shtml ), a place that has recreated many important buildings from colonial days such as the Philidelphia Courthouse and George Washington’s house. On the 4th they have a lot of displays, actors recreating historical moments (the Patrick Henry “Give Me Liberty or Give Me Death” speech is especially good), and tops the day off with music and fireworks.
Happy Birthday U.S.A.!
Getting Started with SQL Server 2005 Full Text Searching: Part 5 – Advanced Searching
Last week we looked at how to search for data by passing a simple search word into a SQL Query that uses Full Text Searching. As you would expect, Full Text Searching is capable of much more powerful searches than a single word.
First, you can search for a phrase. To do so, you include the phrase inside double quotes.
SELECT WebSiteID, WebSiteName
FROM MyTableOfCoolWebsites
WHERE CONTAINS(*, ‘”Arcane Code”’)
Will find occurances of the phrase Arcane Code in your index. Let’s say however, you want to search for either Arcane or Code? FTS supports Boolean searches.
WHERE CONTAINS(*, ‘”Arcane” OR “Code”’)
Will return results where either the word Arcane or Code is in the text. If you want them both, use an AND in place of the OR. Additionally, FTS supports the AND NOT keyword, for when you want the first word but not the second.
Full Text Search also supports something called Proximity searches. In a proximity seach, one word appears near another.
WHERE CONTAINS(*, ‘arcane near code’)
So how near is near? Well the online docs are a bit vague on this, a safe guess is about ten words. You may also see this form of the syntax:
WHERE CONTAINS(*, ‘arcane ~ code’)
~ equates to near, although to me not nearly as readable, be aware though in case you run across it.
Finally, you should be aware that certain words are excluded from searches. Common words such as a, an, the, and so on. Microsoft refers to these as “Noise Words”. You can edit the list of noise words in case you have some words in your environment that wind up being Noise Words. Your company name might be one example.
I found the file in the folder C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\FTData (your milage may vary). The file is named noiseenu.txt. (ENU is for English US, not to be confused with noiseeng.txt which our friends in the British Isles will be using.)
This is also handy to know in case there is a reserverd word you need to remove from the list. In our environment one of the reserve words is also an abbreviation for a piece of our equipment, so I would want to remove this from our list.
Getting Started with SQL Server 2005 Full Text Searching: Part 4 – Valid Data Types
Hopefully everyone had some fun over the weekend with their digital cameras and listening to some good photo podcasts. Today we’ll return to the subject of Full Text Searching (FTS) under SQL Server 2005.
If you’re like me one of your questions is “OK, FTS is great, but exactly what data can I index with it?” Good question, a quck reference of the books online gives us the answer.
Char, nchar, varchar, nvarchar, text, ntext, xml, varbinary(max), and image are the valid data types for FTS. However, according to the documentation text, ntext, and image are going to be removed in a future version of SQL Server, so I’m going to avoid them and so should you.
Char, nchar, varchar, nvarchar are pretty straight forward, and probably expected, so I won’t go into them further. XML is pretty cool, as you may be aware with SQL Server 2005 Microsoft added the ability to store XML in the database. You can then do XML queries into these XML fields, a subject for a future post. However, MS also allows you to search inside these XML fields using Full Text Searching as well.
The final one that needs explanation then is varbinary(max). I’m sure you’re scratching you’re head over this, how can FTS work on binary data? Well remember, the Full Text Search engine is built on top of the Microsoft Indexing Service, which can scan inside Word, Excel, etc files stores on a server.
Thus FTS can actually look inside files stored inside varbinary(max) and if they have the proper extension FTS will look inside them and index the contents of the files. How sweet is that?
Arcane Fun Fridays: Photographic Podcasts
Readers will know I’m a big fan of digital photography, it’s a hobby of mine I like to relax with. For example, here’s a pic I took in downtown Birmingham (the one in Alabama, not England).
I’m also a big beliver in podcasts, I listen to many to educate myself in the .Net world. It occurred to me there’s probably some good photographic podcasts as well, and sure enough I found some good ones. I thought I’d pass along some of the one’s I’ve been listening to, for your listening delight.
The Candid Frame – The host interviews photographers to find out how they got started, their techniques, etc.
Martin Bailey Photography – Martin shares his techniques with us.
Jeff Curto’s Camera Position – Jeff concentrates on the creative side of photography
Tips from the Top Floor – Each week Chris has a new technique for us. You should also check out the forums, they are very active.
Photocast Network – This is a central site for many shows including the ones I’ve listed above. They also have a few other shows I want to check out but haven’t had the opportunity to as of yet.
You should definitely check out the “Focus Ring” episodes. These are shows where the hosts from several of the network’s shows get together on a single podcast to discuss various topics. By far these have been my favorite episodes so far.
There you go, some podcasts to listen to while you’re out playing with that new camera of yours this weekend!
Getting Started with SQL Server 2005 Full Text Searching: Part 3 – Using SQL
OK, so you have this spiffy catalog, and you’ve populated it with full text searches for your favorite tables. Now you’d like to actually use those index from within your SQL. There are four new commands you can use in SQL to get to your data. All are used as part of the where clause, and have similar syntax but different results.
The first is the one you’ll probably use the most, it’s the contains command. You simply pass in the column name and what you want to search for.
select col1, col2 from myTable
where contains(fts_column, ‘searchword’)
For fts_column you can use the name of one of the columns that was indexed, or you can use * (and asterisk) to search in all of the columns that were full text search indexed. In the single quotes you put in the word or phrase you want to look for.
Contains searchs for an exact match. It either finds it or it doesn’t, and it has to be an independent word. For example, if your text field contained “I love the Mythbusters every week.” and you searched for ‘Mythbuster’, would NOT return a match.
If you want your text searching to be a little more open minded, use the freetext command instead. The syntax is identical to contains, including the ability to use an asterisk.
select col1, col2 from myTable
where freetext(fts_column, ‘searchword’)
In this case, however, a search of our afore mentioned text field for ‘Mythbuster’ would return a match, as freetext understands that Mythbuster and Mythbusters are essentially the same word.
In your application, you might consider using a check box that says “exact match”. For exact match queires use the contains keyword, when the user does not check you can use the freetext command.
It’s also possible to return a list of results that are sorted by a rank. The rank indicates the strength of the match to the search phrase passed in. To get a list of ranks, use either the containstable or freetexttable commands. Their syntax is like their cousins, as is the method it uses for searching (containstable is exact, freetexttable is more liberal). The only addition is the first parameter must be the name of the table, then comes the column name and search condition.
Instead of rows, what is returned are two columns: key and rank. The rank is a relative score from 0 to 1000 that indicates the strength of the match. A higher value means it’s a better match.
The key is the primary key from the table you’re searching. You can then use this key to pull back the data from the main table. Let’s do a simple example: you want an exact match for all employees who live in Alabama. Unfortunately the DBA who created the table had just come off a three day drinking binge, and instead of separate street / city / state fields, just created a big text field called emp_address.
select rank, emp_id, emp_name from empTable
join freetexttable(empTable, emp_address, ‘Alabama’) ftt
on empTable.emp_id = ftt.[KEY]
This would return something like:
Rank emp_id emp_name
255 12345 Jamie Hyneman
128 45678 Adam Savage
And there you go, four ways you can have your SQL leverage the power of full text searching to return results.
Getting Started with SQL Server 2005 Full Text Searching: Part 2 – The Indexes
Yesterday I introduced you to full text searching, and covered the basics on creating catalogs to hold your full text indexes. A full text search index is a little different than a regular index. First, each table can only have one full text search index created for it. Next, the create syntax is slightly different. OK, in fact it’s a lot different. Let’s take a look:
create fulltext index on my_table_name_here
(column1, column2,…)
key index my_tables_unique_index_name
on my_catalog_name_here
with change_tracking {manual | auto | off}, no population
The first thing is also the most obvious, you need to supply the name of the table in the first line. Note we’re not supplying a name for the full text search index. Since there’s only one per table, SQL Server takes care of creating the full text search index name for us.
Next we need to supply the name of the column or columns we want indexed. These can be any sort of text field. Just list them one after another, separated by commas.
The next item is also required, and sort of tricky. Each row in the table you are doing full text searching on must have a unique index. It makes sense when you think about it, for the text search to be efficient it must be able to quickly move to the row with the word you’re hunting for, and the way to do that is via the unique index.
So for this parameter you’ll need to supply a unique index name for “my_tables_unique_index_name”. Keep in mind this is not the name of the columns from the table. Instead this is the name of a “normal” index (not a full text search index) that is unique for the table.
The “on” parameter is optional, you only need it if you set up multiple catalogs and don’t have a default. If you omit it, it will simply put the new index in the default catalog.
Next you will need to tell SQL Server how often to update the index. You do this through the with change_tracking parameter. OFF turns it off entirely, no updates will be done until you issue a rebuild via the alter syntax I’ll cover momentarily. You might want to use OFF when you have a table that gets updated very rarely.
AUTO, on the other hand is for when you have a table that gets updated frequently. It will update the full text search index when the associated table is updated. The final option, MANUAL will flag changes to the underlying table, but it won’t update the full text search index until you tell it to.
The final parameter, no population, only applies when you use OFF. It tells SQL Server not to populate the index when it’s created. If you omit it, or use AUTO or MANUAL, SQL Server will populate the full text search index when the index is created.
OK, so you’ve got this index created and need to change it, or perhaps you need to work with one that’s already in existence. For this there’s the alter command:
alter fulltext index on my_table_name_here
parameters here
There’s quite a few parameters you can pass, so let’s look at them individually. Just know that when you see them below, they should go where you see “parameters here” above.
set change_tracking {off | auto | manual} – This works the same as with the create command, it lets you change the tracking mode.
disable – Disables the full text search index, it’s not used for searching nor is it updated. However the data is left intact, should you want to turn it back on.
enable – Enables the full text search index after a disable.
add ( column ) – Adds the passed in column to the full text search index.
drop ( column ) – Removes the passed in column from the full text search index.
start full population –This rebuilds the index from the ground up.
start incremental population –This will update the index since the last time it was updated. Note you must have a timestamp column on your table for this to work.
start update population –Remember a moment ago when I talked about the change_tracking manual option? Well this command is how you update an index with manual change tracking.
And finally, you may decide one day you no longer need the full text search index. Since the readers of this blog are the smartest, most intelligent readers on the planet you’ve already figured out we’ll need to use a variant of the drop command:
drop fulltext index on my_table_name_here
And there you go, you now know how to create, change, or remove a full text search index. Now there’s one more piece, you need to know how to use them from within your SQL. But we’ll save that for tomorrow.
Getting Started with SQL Server 2005 Full Text Searching: Part 1 – The Catalog
One of the coolest features of SQL Server 2005 is the ease with which you can implement full text searching. True, it was available in previous versions but 2005 makes it very easy to implement and use.
Full Text Search is an offshoot of the Microsoft Index Server technology. It’s what you could call an “add-on”. By default it’s enabled for every database you create in 2005.
But just having it turned on is not enough, now you have to create a catalog to hold the data for your full text data. The catalog is a separate file from your database, and holds all the key words it finds. The syntax to create a catalog is pretty simple:
create fulltext catalog my_catalog_name_here
in path ‘c:\mysqldata\somesubdirectory’
as default
The ‘in path’ is optional, if you omit it your catalog is created in the same place as the data. For small databases this is fine, for large ones you might actually want to store the catalog on a separate hard disk in order to get a performance boost.
The ‘as default’ clause says this catalog will be the default one used for new full text search indexes, or for searching existing ones. Most times you’ll probably only need one catalog for a database, so you can add this and forget it.
Once you have a catalog created, you may need to tweak it. There’s not a lot of tweaking you can do, just three ways you can alter it, and all are implemented via the alter command.
alter fulltext catalog my_catalog_name_here rebuild
alter fulltext catalog my_catalog_name_here reorganize
alter fulltext catalog my_catalog_name_here as default
The first command, rebuild does just what it says. Your old catalog goes to the great bit bucket in the sky (i.e. it’s deleted) and SQL Server will recreate all of your full text search indexes. And it should be obvious, but remember during this time your full text search will not be available.
Reorganize is something like doing a disk defrag, it cleans up and reorganizes your full text search indexes. While it may not be as efficient as doing a complete rebuild, it does have the advantage of not taking the catalog offline while it does it’s work.
Finally ‘as default’ simply makes the catalog the default, in case you either forgot or were distracted by Mike Rowe doing something nauseating on “Dirty Jobs” (http://www.discovery.com/dirtyjobs) .
OK, you now have a catalog. But the catalog is simply a space to hold your full text search indexes, and those we’ll create in the next post.
Collections in C#: NameValueCollection
In doing some reading I ran across a handy collection called the NameValueCollection. This collection, which resides in the System.Collections.Specialized namespace, allows you to use either a string or an integer index for the key. Further, it allows you to store more than one string value in a key.
Let’s start the code example by creating a simple Console application. I added using references to System.Collections and System.Collections.Specialized namespaces at the top. As a final bit of housekeeping, make sure to add a Console.ReadLine() as the last line of our code, so the console will wait on us to hit the enter key after we read the results. (If you don’t, the program will run so fast you won’t be able to appreciate your fine work.)
Now I’m going to load some data into a new collection called myCollection. For the data, I’ll use a website owner and the website or sites they own.
System.Collections.Specialized.NameValueCollection myCollection
= new System.Collections.Specialized.NameValueCollection();
myCollection.Add(“Arcane”, “http://arcanecode.com”);
myCollection.Add(“PWOP”, “http://dotnetrocks.com”);
myCollection.Add(“PWOP”, “http://dnrtv.com”);
myCollection.Add(“PWOP”, “http://www.hanselminutes.com”);
myCollection.Add(“TWIT”, “http://www.twit.tv”);
myCollection.Add(“TWIT”, “http://www.twit.tv/SN”);
Next, I’d like to get some data back out. I mentioned you could cycle through the collection using an integer index, so let’s see how that’s done:
Console.WriteLine(“Key / Value Pairs by Integer Index”);
for (int i = 0; i < myCollection.Count; i++)
{
Console.WriteLine(i.ToString() + ” “
+ myCollection.GetKey(i) + “: “
+ myCollection.Get(i));
}
In the above output you can see how I use the GetKey and Get methods to retrieve the key name and value for that key using the loop’s index. Note that when multiple values are associated with a single key, they are returned as a list of comma separated values.
You can also use foreach logic to cycle through the collection. Here I am using the AllKeys property of our collection to get the list of keys. I can then print the key, and also use the key as the indexer into my collection as you can see below.
Console.WriteLine();
Console.WriteLine(“Keys / Value Pairs via AllKeys Collection”);
foreach (string myKey in myCollection.AllKeys)
{
Console.WriteLine(myKey + “: “ + myCollection[myKey]);
}
Now I, what? Yes, you in the back row, what was your question? Ah, you say lists of comma separated values are OK, but you want to be able to access individual values? Fortunately some nested looping and the GetValues method will satisfy you demanding types.
Console.WriteLine();
Console.WriteLine(“Keys / Individual Values”);
foreach (string myKey in myCollection.AllKeys)
{
foreach (string myValue in myCollection.GetValues(myKey))
{
Console.WriteLine(myKey + “: “ + myValue);
}
}
myCollection.Add(“CommaTest”, “Here is a , in a string”);
myCollection.Add(“CommaTest”, “Here is another , in a string”);
As you can see in the last area “Keys / Individual Values” the GetValues method correctly determined that the commas I had embedded were part of the data and not a delimiter between values.
Whenever you need a good string collection that has the ability to tie multiple values to a single key, the NameValueCollection would be a good class to take a look at.