Monday 28 September 2009

VB .NET Converter

First, worth to try the VS built in converter.

Another one that looks good, worth a try http://www.aivosto.com/project/vbnet.html - says it works with previous versions and there is trial for small projects.

Microsoft Visual Basic 6.0 Code Advisor can be used on VB6 before converting to VB.NET:
http://msdn.microsoft.com/en-us/vbasic/ms789135.aspx

Finally a couple of more:

http://www.vbto.net/

http://www.vbmigration.com/editions.aspx

Other useful links for migration of VB6 to .NET

http://blogs.msdn.com/ericnel/archive/2008/04/25/visual-basic-6-migration-to-net.aspx
http://msdn.microsoft.com/en-gb/vbrun/ms788233.aspx
http://msdn.microsoft.com/en-gb/dd408373.aspx

Finally here is a promissing link for 5 to 6 but can't follow it at the moment: http://www.topblogarea.com/sitedetails_17682-2.html

Thursday 24 September 2009

how to get the default schema for a user in MSSQL 2005

execute the stored procedure sp_helpuser, for example


sp_helpuser 'domainname\username'

One of the resulting columns is DefSchemaName.

There is a similar proc sp_helpgroup to show the users in a group but does not include schema information.

Another way to get the schema information is

select name, default_schema_namefrom sys.database_principals uwhere u.name='username'

Tuesday 22 September 2009

SQL tutorials

Nice website with tutorial but requires google gears to run the examples.
http://www.bin-co.com/database/sql_tutorial/

Visual Explanation of JOINs http://www.codinghorror.com/blog/archives/000976.html

SQL replicate permissions (copy)

Found the following cool script at http://vyaskn.tripod.com/scripting_permissions_in_sql_server_2005.htm

along with a very good explanation


   1:  SET NOCOUNT ON
   2:  DECLARE @OldUser sysname, @NewUser sysnameSET @OldUser = 'HRUser'SET @NewUser = 'PersonnelAdmin'
   3:  SELECT 'USE' + SPACE(1) + QUOTENAME(DB_NAME()) AS '--Database Context'SELECT '--Cloning permissions from' + SPACE(1) + QUOTENAME(@OldUser) + SPACE(1) + 'to' + SPACE(1) + QUOTENAME(@NewUser) AS '--Comment'SELECT 'EXEC sp_addrolemember @rolename =' + SPACE(1) + QUOTENAME(USER_NAME(rm.role_principal_id), '''') + ', @membername =' + SPACE(1) + QUOTENAME(@NewUser, '''') AS '--Role Memberships'
   4:  FROM sys.database_role_members AS rm
   5:  WHERE USER_NAME(rm.member_principal_id) = @OldUser
   6:  ORDER BY rm.role_principal_id ASC
   7:  SELECT CASE 
   8:  WHEN perm.state <> 'W' 
   9:  THEN perm.state_desc 
  10:  ELSE 'GRANT' 
  11:  END + SPACE(1) + perm.permission_name + SPACE(1) + 'ON ' + QUOTENAME(USER_NAME(obj.schema_id)) + '.' + QUOTENAME(obj.name) + 
  12:  CASE WHEN cl.column_id IS NULL THEN SPACE(0) 
  13:  ELSE '(' + QUOTENAME(cl.name) + ')' 
  14:  END + SPACE(1) + 'TO' + SPACE(1) + QUOTENAME(@NewUser) 
  15:  COLLATE database_default + CASE WHEN perm.state <> 'W' 
  16:  THEN SPACE(0) 
  17:  ELSE SPACE(1) + 'WITH GRANT OPTION' END AS '--Object Level Permissions'
  18:  FROM sys.database_permissions AS perm 
  19:  INNER JOIN sys.objects AS obj ON perm.major_id = obj.[object_id] 
  20:  INNER JOIN sys.database_principals AS usr 
  21:  ON perm.grantee_principal_id = usr.principal_id 
  22:  LEFT JOIN sys.columns AS cl 
  23:  ON cl.column_id = perm.minor_id 
  24:  AND cl.[object_id] = perm.major_id
  25:  WHERE usr.name = @OldUser
  26:  ORDER BY perm.permission_name ASC, perm.state_desc ASC
  27:  SELECT CASE WHEN perm.state <> 'W' THEN perm.state_desc 
  28:  ELSE 'GRANT' END + SPACE(1) + perm.permission_name + SPACE(1) + SPACE(1) + 'TO' + SPACE(1) + QUOTENAME(@NewUser) 
  29:  COLLATE database_default + 
  30:  CASE WHEN perm.state <> 'W' THEN SPACE(0) ELSE SPACE(1) + 'WITH GRANT OPTION' END AS '--Database Level Permissions'
  31:  FROM sys.database_permissions AS perm 
  32:  INNER JOIN sys.database_principals AS usr 
  33:  ON perm.grantee_principal_id = usr.principal_id
  34:  WHERE usr.name = @OldUser
  35:  AND perm.major_id = 0
  36:  ORDER BY perm.permission_name ASC, perm.state_desc ASC

Saturday 19 September 2009

outlook express with windows live email and o2 smtp settings

Finally I got this to work, the tricky bit was using SMTP port not the 25 default but 587 (as I discovered somewhere on the web). Here are the screenshots of the settings:

The server settings:

The server authentication settings:

Note that in the above image you can enable the "Log on using Secure Password Authentication" and it will still work. Or you can use the option "Use same settings as my incoming mail server" and it will still work - actually this is a bit easier since you dont have to enter the same information twice.

Finally the advanced settings:


Wednesday 9 September 2009

XML and XPATH editor : SketchPath

Free and open source not open source: http://pgfearo.googlepages.com/

Update Nov 2012:

On the original page now states:

SketchPath as a product has evolved into 2 very different products that include SketchPath's powerful XPath features, but also bring new features to the mix:

XMLQuire

Windows XML editor with integrated XPath 1.0 editor

Pathenq

Simple, yet powerful web-based XPath 2.0 editor - with built-in diagnostics tools


The first one is free, the second online. A very good tool.

Monday 7 September 2009

ForFiles command - windows server 2008

forfiles command is quite useful as it has the /d switch (date) which can be set to less than 30 days (-30) or more. The /m is a mask that you can set to the extension of files you wish to find to save you from doing a *.*. Then it will do the command in “ “ for each file that meets the criteria.

Example

This deletes any files in c:\a:\test and its subdirectories that are older than 30 days:


   1:  forfiles /p /m *.txt c:\a\test /s /c "cmd /c del @file" /d -30