September 2006 - Posts

Responsible Managment of XML DOM's

Folks:

Since System.Xml.LoadXml(strXml) creats an in-memory instance of the System.Xml.XmlDocument you give it, memory usage could possibly become a factor and affect performance in a given application. 

Therefore, in the spirit of good coding practices, what is the responsibility of the developer when you are done with the XML DOM and want to free up memory? 

A. Invoke System.Xml.XmlDocument.RemoveAll()

B. Use the Destructure Supplied with the XmlDocument Class

C. Let it go out of Scope let the CLR Garbage Collector clean it up.

D. Other (Explain)

Please cast your vote. I value your feedback. 

Fletcher Dunton
MCAD, MCP

 

 

with 0 Comments

Fix for Error 21002: [SQL-DMO] User already exists

I cloned a database back from our DEV server to my local server and it had 1 user account called "webuser". That account had execute permissions on about 120 stored proc's.

When I tried to create this user under my LOCAL Server's Security\Login folder, I got the following error: "Error 21002: [SQL-DMO] User 'webuser' already exists."  So I went to my database\User folder and try and delete the account and it tells me "The Selected User Cannot be dropped b/c it owns objects".  

The long way to fix the problem was to hit the permissions button and uncheck all 120 exec priv's on the SP's and then delete it. ....ZZZZZzzzzzz [xx(].

But,  amwhite  provided me a much more efficeint way to accomplish this and here it is:

  1. Use sp_addlogin to create the webuser login with an appropriate password.
  2. Next, logged in with a sysadmin account, connect to the cloned database and issue the following command: sp_change_users_login 'Update_One', 'webuser', 'webuser'
  3. After that's done, you can go back to the login properties and set the default database for webuser to your cloned database.

This works nice. 

Thanks again,  amwhite

Fletcher Dunton
MCAD, MCP

with 0 Comments