Thursday 30 October 2008

SQL Server Language Settings

This is to solve the problem where we want to be using British English in SQL but it insists in using US English.


   1:  PRINT @@LANGUAGE

Will show you current default server language (should be British).


   1:  sp_defaultlanguage 'your-domain\your-username'

will make your username take on the default of the server. (of course replace username with the one you want to change). If the logins are done via groups and not individual users, you will need to change the group's default language (by using the group instead of the specific user as parameter to sp_defaultlanguage).

also read for more information:

sp_defaultlanguage doc:
http://doc.ddart.net/mssql/sql70/sp_da-di_7.htm

default language options:
http://msdn.microsoft.com/en-us/library/aa196707(SQL.80).aspx

sp_configure doc:
http://msdn.microsoft.com/en-us/library/aa259616(SQL.80).aspx

If all fails you can use SET DATEFORMAT eg


   1:  SET DATEFORMAT dmy

for European, inside the stored procedure you are executing, but I prefer the first solution based on user settings. On the other hand the SET DATEFORMAT command in the stored procedure makes it more robust, its up to you.

Failing all can use:


   1:  ALTER LOGIN user1 WITH DEFAULT_LANGUAGE = British

Friday 24 October 2008

Programmatically select DataGridView row

This can be useful if we are updating a row in a DataGridView and we want to refresh the DataSource, still the selected row to remain the same.


   1:  if (selectedIndex > -1 && dataGridView1.Rows.Count > selectedIndex)
   2:  {
   3:      dataGridView1.Rows[selectedIndex].Selected = true;
   4:      dataGridView1.FirstDisplayedScrollingRowIndex = selectedIndex;
   5:  }

Monday 20 October 2008

Recycling

Freecycle (www.freecycle.org) is a place to pass along no longer needed items and possibly find something you need - better passed along than in a landfill. A LaserJet III probably won't be your first choice for a business proposal or resume, but it's OK for a draft copy of anything or printing a program listing. It's a great deal if it's free and toner cartridges are still plentiful and cheap.

Craig's List (www.craigslist.org) has free, for sale, and wanted sections. You can find lawn and garden, furniture, computers, entertainment gear, kids' stuff and lots more. That 18 year old truck was sold via Craig's list and I had cash-in-hand in 24 hours from the time the ad was posted - there's no charge to post or sell on Craig's List.

Portable database VistaDB

This is an alternative to sqlite, http://vistadb.net/vistadb3/features.aspx. Although it is commercial, they also offer a free version. The database is written in .NET and seems to have all the basic features you would want. Worth considering for projects requiring a small database.

Tuesday 14 October 2008

Active directory group and member properties, DirectorySearcher PropertiesToLoad possible values

Normally you would use code like this, to retrieve values for specific properties of an Active Directory group (specified in string groupName):


   1:  DirectorySearcher search = new DirectorySearcher {Filter = String.Format("(cn={0})", groupName)};
   2:  search.PropertiesToLoad.Add("member"); 
   3:   
   4:  List<string> userNames = new List<string>();
   5:   
   6:  if (result != null)
   7:  {
   8:     for (int counter = 0; counter < result.Properties["member"].Count; counter++)  
   9:     {
  10:        string user = (string)result.Properties["member"][counter];
  11:        userNames.Add(user + Environment.NewLine);
  12:     }
  13:  }
  14:   
  15:  return userNames;

but what are the possible values of properties you can use in PropertiesToLoad.Add()? I couldnt find this information anywhere so I wrote a little snippet to retrieve them, here is the result (29 properties)

textencodedoraddress
distinguishedname
dscorepropagationdata
grouptype
objectsid
whencreated
msexchalobjectversion
mailnickname
name
usnchanged
objectcategory
samaccounttype
instancetype
reporttooriginator
cn
proxyaddresses
showinaddressbook
objectclass
mail
usncreated
member
objectguid
adspath
displayname
legacyexchangedn
samaccountname
whenchanged
memberof
msexchpoliciesincluded

The best programming fonts list... ever

http://www.codeproject.com/KB/work/FontSurvey.aspx

Thursday 9 October 2008

XML command line manipulation open source utility

This might be handy if you have to do a lot of work with XML, or even to quickly query large XML files that you want to search for specific information, although I don't know how well it can deal with large files:

http://xmlstar.sourceforge.net/

Tuesday 7 October 2008