Fixing up usernames after SQL Server Database Restore#

The problem is that if you restore a sql server database on a different computer than the backup was created, you can have the problem that the usernames and permissions are somewhat lost.

Each username has an associated SID.  So even though you might have a user named 'Bill' and the restore database might have a user named 'Bill', they will have different SIDs and so the permissions will not be applied to the correct user.

To fix this problem you can follow the following steps:

1) run this TSQL:

sp_change_users_login 'report'

2) This will produce a table showing you Users that having issues.

3) run the following TSQL:

sp_change_users_login 'update_one', 'UserNameFromStep2Table','NameOfUserToUse'

In many cases the 2nd and 3rd parameters will be the same string.

More about this SP can be found here: http://doc.ddart.net/mssql/sql70/sp_ca-cz_4.htm

 

Categories:  |  |  | 
Thursday, May 25, 2006 3:20:46 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Free Anti Virus Software Options#

Slashdot recently posted a question from a user asking what the best free anti virus options are.

The response can be seen here:

http://ask.slashdot.org/article.pl?sid=06/05/22/1310211

 

Categories:  |  | 
Thursday, May 25, 2006 12:36:09 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Network Associates/McAfee mytilus.dll crashing my computer#

I am getting a little sick of this.

Starting with a few days ago I started getting a lot of these errors.  Mostly in IE, but also in VS.Net.

Looking at the details of the error I see it is coming from mytilus.dll, which is a DLL used by VirusScan 8.  I have patch 11, which I guess is up to date.  I will be keeping an eye on it.

Categories:  | 
Wednesday, May 24, 2006 1:12:22 PM (Central Standard Time, UTC-06:00) #    Comments [3]  | 

 

Activate Flash, Movies, and other ActiveX controls#

Recently Microsoft lost a patent judgement, which resulted in them pushing down an "update" to IE that forces you to click on any embedded object to "activate" it.

Embedded objects can be flash movies, video clips, audio, etc.

This is really bad for sites that use flash.  Things like navigation and rollovers don't work until you first click on them.

This article talks about the work around, and how you can incorporate this into your ASP.NET projects.

http://www.codeproject.com/aspnet/IEActiveXActivation.asp

 

Categories:  |  | 
Wednesday, May 24, 2006 12:43:58 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

5 Rarely used XHTML elements#

This article is pretty interesting, as it discusses 5 xhtml elements that most people don't know about or use.

1) OptGroup





 
2) label (click the "Full Name")

Gender: 

 

3) fieldset/legend

CommentsCP is a good place to publish XHTML related articles.
www.google.com can search

Personal Information Gender: 

4) col/colgroup (notice the control over col widths)

1   2
3   4

 

5) Acronym (mouse over xhtml)

CP is a good place to publish XHTML related articles.

 

These are not widely known but very useful.

Categories:  | 
Wednesday, May 24, 2006 12:15:47 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

iDont.com#

Almost all of my friends have IPods, but I have held off. 

There are a number of reasons why:

1) ITunes:  It sucks.  I hate it.  My current MP3 player simply allows you to drag and drop the files you want onto your MP3 player.  No syncing, no problems.

2) User interface.  I know a lot of people think the wheel is really cool, but I think it overly involves the user.  Tell me what is wrong with up/down buttons before you redesign the interface to use a wheel.

3) Batteries.  As noted at http://www.ipodsdirtysecret.com/.  The battery in an IPod can not be removed, and some say they start to fail after 18 months.

Well I came across a site called http://www.idont.com/, which went live today (before today it had some anti-ipod message up there). 

Turns out it is a site for the new SanDisk MP3 player.

The e200 (really catchy name... not) looks pretty cool, and might be worth me looking into more: http://www.anythingbutipod.com/archives/2006/03/sandisk-sansa-e200-series-review.php

 

Categories:  |  |  |  | 
Monday, May 22, 2006 12:19:38 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Secret Machines#

This weekend I went to see a band called Secret Machines, or The Secret Machines.  They seem to split the naming thing about 50/50 between using the "The" and not using it.

Anyway, they were playing a show at midnight at the Metro, which was kinda cool.  There was no opening band, so we got in around midnight and they came on around 12:20 or so.  I hate waiting hours for a band to come on stage, so that was as big plus.

It was crowded in there, but not too croweded.  When I saw 311 in the same place it was insane.  They couldn't have packed more people in there if they wanted to.

Secret Machines played most of the songs I know: they only have 3 CDs.  And, they did this cool thing at the end of the show they setup their guitar in some kind of loop and left it on stage with the strobe lights and fog machines going full blast as they exited the stage.  The loop continued for another 20 seconds or so before snapping off and the lights for the venue came on.  Pretty cool!

Categories:
Thursday, May 18, 2006 3:20:15 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Microsoft Releases LINQ CTP#

Microsoft has released LINQ CTP.

While it is not expected that this will become fully released until the next version of Visual Studio (2008?) it is not something bad to look at now.

Categories:  |  |  | 
Wednesday, May 17, 2006 7:47:12 AM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Creating a Sortable BindingList#

This article from MSDN talks about custom databinding, but specifically it talks about the issues raised when you are trying to databind a custom collection to a datagridview.

Using a List<T> will work, but when all is said and done you lose some nice features such as sorting.

Categories:  |  |  |  | 
Wednesday, May 17, 2006 7:43:51 AM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

ReportViewer in LocalReport Mode With Subreports And Business Objects#

There are not many good examples of how to do stuff like this.  So the article below was all the more helpful when I was building a somewhat complex report.

http://www.codeproject.com/dotnet/AdoNetForOopPart2.asp?df=100&forumid=258341&select=1482558&msg=1482558

 

Categories:  |  |  | 
Wednesday, May 10, 2006 8:07:29 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Nice RegEx Overview / Test Page#

I don't often need regular expressions, but when I do need them it is nice to have a page that gives you a quick index and even a place to test it out.

That is exactly what this page has:

http://www.quanetic.com/regex.php

keyword: regexp

Categories:
Wednesday, May 10, 2006 12:57:26 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Run ASP.NET Web Server From Any Folder#

Rob McLaws has this cool extension that lets you click on a folder and run a webserver from it.

The article, with some comments on alternative ways to do it, or ways to improve it can be found here.

http://weblogs.asp.net/rmclaws/archive/2005/10/25/428422.aspx

From the page:

I've been doing some web development work again lately, and I haven't wanted to screw with setting up IIS on my virtual machine. The .NET Framework 2.0 comes with a built-in webserver, based on the old Cassini web server. So I wanted to be able to easily set up any directory to have its contents served up on an as-needed basis. The result is an addition to the Windows Explorer right-click menu, as shown below:

This is enabled by a simple modification to the registry. You can take the text below and dump it into a file named "WebServer.reg", and then run it, to immediately get the item in the context menu.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\VS2005 WebServer]
@="ASP.NET 2.0 Web Server Here"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\VS2005 WebServer\command]
@="C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727\\Webdev.WebServer.exe /port:8080 /path:\"%1\""

There are a couple caveats to this tool, however:

  1. The web server does not randomly assign a port number, so it has to be hard-coded into the registry.
  2. The web server does not automatically assign a virtual directory, so it will always be "http://localhost:port"
  3. A command prompt window will be spawned, and cannot be closed without closing the web server process.

Moving foward, there are a couple of options to fix these issues:

  1. Someone who knows more about variables in the registry can help me fix issues #2 and #3
  2. I can build a wrapper executable that solves all three problems
  3. Microsoft can put in a DCR and fix it before it goes gold in a few days.

#3 is not likely, so I'd love to hear what you think. Hope this trick is useful.

 

Categories:  |  |  | 
Tuesday, May 09, 2006 2:55:26 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Dropdown1 has a SelectedValue which is invalid because it does not exist in the list of items.#

'Dropdown1' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value

This error has been a real pain to deal with.  I finally have a work around and a guess at the underlying problem, and because I see that people are having this same problem I thought I would do a little writeup about it.

 

Obviously, if you look at the actual error message, there are cases when you can get this message and the problem is easy to solve.  e.g. you have a dropdown populated with EmploID values and you try to databind with: 

Value='<%# Bind("EmployeeName") %>

 
Well of course that won't work if all your values are integers and you are trying to set the value to "Bill Smith".
 
But my problem was a bit more complicated.
 
I was building a web user control (aka ASCX) that was a "Location" dropdown.  The control basically contains a dropdown, and all the necessary logic to populate the dropdown, and I was trying to use this control inside the EditTemplate of a GridView.
 
To make things more complicated, in this case, I didn't JUST want all the Locations, I also wanted to add a "Please Select" item to the list, with a value of 0.
 
But I kept getting the error above when the value was supposed to be 0.
 
I stepped through my code to try to find out what was going on.  I believe the issue is this:
 
On load, on value set, and on databind I call my "Populate" method.  This method sees if there are items in the dropdown.  If not, it gets a list from the database and binds to the dropdown.  It also checks if there is a "Please Select" item, and adds it if there isn't one.
 
But still when Dropdown's "DataBound" event was fired the last time, my manually added item had been removed.
 
So what I think what is happening is that :
1) I set the dropdown DataSource to a collection of business objects
2) I add the "Please Select" item
3) The dropdown is told to databind itself by the Gridview.
4) The dropdown says... "Oh, I do have a datasource, so I'm going to ditch my current list and rebind to that old collection"
5) The dropdown says "Holy shnikies, I am supposed to bind to value "0", but I don't have one!!"
 
I think there are 2 possible solutions.
 
1) I created an adapter class that only has Id and Description properties that are going to be used by the control, and I wrote a function to take my collection of business objects and build a collection of Adapters (adding my "Please Select") to the list of adapters.  To see what I am talking about I will post this code below.
 
2) Manually add items to the dropdown instead of databinding, so that when the control is told to databind, it doesn't have a datasource to use.
 
 
Here is my adapter code:
            '**** In my populate method
Me.LocationsDropdown.DataSource = LocationAdapter.LocationsToAdapters(locations)
Me.LocationsDropdown.DataTextField = "LocationDescriptionWithActiveAttribute"
Me.LocationsDropdown.DataValueField = "LocationId"
Me.LocationsDropdown.DataBind()



'*************************************
'*************************************




Private Class LocationAdapter
Public ciLocationId As Integer
Public csLocationDescriptionWithActiveAttribute As String
Public Property LocationId() As Integer
Get
Return ciLocationId
End Get
Set(ByVal value As Integer)
Me.ciLocationId = Value
End Set
End Property

Public Property LocationDescriptionWithActiveAttribute() As String
Get
Return csLocationDescriptionWithActiveAttribute
End Get
Set(ByVal value As String)
Me.csLocationDescriptionWithActiveAttribute = Value
End Set
End Property

Public Sub New(ByVal loc As Location)
Me.LocationId = loc.LocationId
Me.LocationDescriptionWithActiveAttribute = loc.LocationDescriptionWithActiveAttribute
End Sub
Public Sub New(ByVal Id As Integer, ByVal Desc As String)
Me.LocationId = Id
Me.LocationDescriptionWithActiveAttribute = Desc
End Sub

Public shared Function LocationsToAdapters(ByVal locations As List(Of Location)) As List(Of LocationAdapter)
Dim adapters As New List(Of LocationAdapter)
adapters.Add(New LocationAdapter(0, "--Location"))
For Each loc As Location In locations
adapters.Add(New LocationAdapter(loc))
Next
Return adapters
End Function

End Class
 
 
 
Categories:  |  | 
Sunday, May 07, 2006 1:45:48 PM (Central Standard Time, UTC-06:00) #    Comments [5]  | 

 

Windows XP "Help and Support" Start Menu#

I never ever ever want to click on the "Help and Support" button in the WinXP start menu, but I frequently do when trying to click on something else (usually "Run...").

I found this info on http://www.winxptutor.com/hidehlp.htm

To remove the Help and Support link from XP Start Menu, try this:

  • Right-click Taskbar, choose Properties
  • In the Start Menu tab, click Customize
  • Select the Advanced tab
  • Uncheck Help and Support option.
  • Click OK, OK and close the dialog

For Windows Classic Start menu, you may need to modify the registry directly:

  • Click Start, Run and type Regedit.exe
  • Navigate to the following location:

HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced

  • In the right-pane, create a new REG_DWORD value named NoStartMenuHelp
  • Double-click NoStartMenuHelp and set it's value to 1
  • Close Regedit.
Categories:  |  | 
Friday, May 05, 2006 12:45:48 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

AWStats#

This is a well known log analyzer application that can provide a nice web interface for viewing we stats.

http://awstats.sourceforge.net/ 

Categories:  |  |  |  | 
Thursday, May 04, 2006 2:55:16 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

Adding a Single Project To Source Control? #

In previous versions of VS.Net you could take a project and go File->Source Control->Add Selected Project To Source Control and you could simply add the project to your VSS provider.

Now in VS.Net 2005 (maybe caused by VSS 2005, or VSS 2005 over HTTP), if you follow this route you will end up with File->Source Control->Add Project to Source Control, and your project will be added with the following path:

$\MyProject.root\MyProject.

Thanks VSS, thanks a lot.  I really needed that .root in there.

To get around this problem, just add another existing project to VS.Net (creating a solution).  Now highlight the actual project you want to add and do:

File->Source Control->Add Selected Project to Source Control and all will be wonderful.

Categories:  |  |  | 
Tuesday, May 02, 2006 1:43:04 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

GirlSpeak to English#

This is really funny!  I used to joke that I was going to write a book about this stuff, but this page about sums it up.

GirlSpeak to English Translator

Example:

She says                               English
---------                              -------
We need                                I want
Do what you want                   You'll pay for this later
We need to talk                      I need to complain

Categories:
Tuesday, May 02, 2006 1:29:44 PM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

No Tools->Macros in VS.Net 2005#

Some people I work with have no Macros menu under Tools in vs.net 2005.

I am still trying to figure this one out, but in the mean time you can access most of the features with the following shortcuts:

Categories:  |  | 
Tuesday, May 02, 2006 9:44:43 AM (Central Standard Time, UTC-06:00) #    Comments [0]  | 

 

All content © 2008, Christopher May, Inc
Open Job Positions
On this page
Google Ads
This site
Calendar
<August 2008>
SunMonTueWedThuFriSat
272829303112
3456