Thursday, April 24, 2008

Syntax for Output Parameter C#

protected void RolesToBeMade(int RoleID, int DepartmentID)

string strConnString = ConfigurationManager.ConnectionStrings["jk_devConnectionString"].ConnectionString;
SqlConnection conn = new SqlConnection(strConnString);
errMsg.Visible = false;


SqlCommand DBCmd = new SqlCommand("insDepartmentRole", conn);
DBCmd.CommandType = CommandType.StoredProcedure;

SqlParameter paramRID = new SqlParameter("@_RoleID", SqlDbType.Int, 10);
paramRID.Value = RoleID;

SqlParameter paramDID = new SqlParameter("@_DepartmentID", SqlDbType.Int, 10);
paramDID.Value = DepartmentID;

SqlParameter sqlOut = new SqlParameter("@_result", SqlDbType.Int);
sqlOut.Direction = ParameterDirection.ReturnValue;



Int32 intI;

intI = (Int32)DBCmd.Parameters["@_result"].Value;

if (intI != 0)
throw new ArgumentException("Database Error");
catch (Exception err)
util.logging.Log2file(err.Message.ToString(), Server.MapPath("~") + "
\\Logging.log", 10000);
errMsg.Visible = true;
errMsg.Text = "Sorry, an error occurred. Please try your request again at another time.";

How to use VS 2003 on Vista

1.) Visual Studio 2003 is not supported on Vista (per M$). While VS2k3 binaries will run on Vista and VS2k3 code can/will compile on Vista, Vista in not a suitable OS for a VS2k3 development machine. Use 2k Pro+ or XP Pro+
2.) This document is specific to web projects
3.) Version of Vista was/is 64 bit Ultimate (only relevant to a few steps)


1.) .Net Framework 1.1
2.) .Net Framework 1.1 (Very important – otherwise you will get a rather obtuse error)
1.) Ensure "c:\Windows\Microsoft.NET\Framework\v1.1.4322\mscorsvr.dll" is version 1.1.4322.2032 or higher
2.) IIS 6.0 or later (7.0 comes w/ Vista versions Premium and above)

Detailed: (Source: URL_1)

1.) Enable IIS 6.0 compatibility
· Open "Control Panel"
· Double-click "Programs and Features"
· Expand "Internet Information Services"
· Expand "Web Management Tools"
· Check "IIS 6 Management Compatibility"

2.) Register v1.1 with IIS
· Open a CMD prompt
· Change your directory to c:\Windows\\Framework\v1.1.4322
· Run "aspnet_regiis -ir -enable"
· "ir" registers v1.1 with IIS but doesn't change any existing script mappings
· "enable" marks aspnet_isapi.dll as "Allowed" under "ISAPI and CGI Restrictions"
· aspnet_regiis should also create a new AppPool under "Application Pools" called "ASP.NET 1.1" that is configured with the "Classic" pipline, and "Enable32BitAppOnWin64" set to true if a 64-bit OS.

3.) Make the new "ASP.NET 1.1" appPool the default.
· Open the IIS manager
· Select the "Web Sites" folder.
· Under "Actions" on the upper right, click "Set Web Site Defaults..."
· Change the "Application Pool" setting to "ASP.NET 1.1"

4.) Setup your user account as a local admin (you want to be in the Debugger User group but this will take care of that) URL_2

5.) Switch off the "user account control" (optional) [msconfig] [tools] [Disable UAC] URL_3

6.) IIS – make sure “Front Page Extentions” installed (under WWW Services) (via Add / Remove Windows components)

7.) IIS – make sure “IIS 6.0 Compatibility” installed (under WWW Services) (via Add / Remove Windows components)

8.) Make sure WWW Services service is running (and IIS, while you’re at it…)

9.) IIS – server level – “ISAPI & CGI restrictions” – ensure ASP v1.1 enabled (may be able to set at application level and skip step 13 but I did not try)

10.) New virtual directory
a. ASP properties – allow client and server side debugging (even though you won’t be able to debug anyway)
b. Authentication – Windows

11.) Verify web site started

12.) Make project, verify web.config value for debug = true (even though you won’t be able to debug anyway)

13.) Reset any 2.0 sites to use “Default Application Pool” (2.0) in IIS

14.) If you get an error like “URL is in the internet zone” change your project properties to local host

a. From “http://netbios and domain/WebApplication1
b. To “http://localhost/Web Appliation1/

Other/Related items

#1.) New boxes from IT may be missing some web hosting components (hear head banging on desk now)
(Note I am on Vista 64 bit, IIS 7.0)
a.) Under add/update/remove Windows components, under IIS, under wwws (world wide web services) there are several options – check them all. I think in other OS’s that wwws is on the same level, not under, iis. I’ve isolated it to this level (but not the exact subcomponent). My solution also worked for Mike who is on XP. Symptom is that IIS cannot serve up any kind of asp(x) page, only htm(l) will work

#2.) (SQL Server) While the 32 bit client tools for 2K (except for EM) work well with 2K5 (and are much lighter weight) the 32 bit 2K tools (query analyzer) does not work with 2K5 64 bit




Debugging client JavaScript in VS 2005

"...One of less known features of Visual Studio 2005 is Script Explorer, hidden in Debug menu where appears only when the debugger is running. This great tool allows easily debug JavaScripts..."

SQL Server 2005 Long Varchar Storage

2k vs. 2k5 difference – 2k5 will allow table content to exceed 8060 chars – it puts in a 24 bit ref. & stores the offending data in a different page. Not a great idea but it does prevent the app from breaking.

SQL Server 2005 Security Option

Had an ap all of a sudden just stop working today …

Logon Error: 18487, Severity: 14, State: 1. Logon Login failed for user 'loginname'. Reason: The password of the account has expired. [CLIENT: ]

Then the password for the login used in your web application has expired. SQL Server 2005 introduced 'Enforce password policy' and/or the 'Enforce password expiration' configurations which use the local policies for password length, complexity and expiration. Depending on how Active Directory, the local policies and your rights are setup, these parameters can be reviewed and changed to dictate how SQL Server uses configurations.

Differences in SQL Profiler 2000 & 2005

Between Sysobject changes and changes in the UI for SQL Profiler you may run into some unexpected results when trying to trace DB commands (especially if you are trying to trace on only a specific db (recommended – profiler is a rather heavy tool)).

You may find the below chart of assistance. Note – in the 2005 version of profiler there is a checkbox on the “Filter” dialogue called “Exclude rows that do not contain values” (this does not exist for the 2000 version). Your filters will not be applied unless this box is checked. Additionally this option is not available when using 2005 tools on a 2000 DB.

Cascading add sub-dirs to vss project

If, when you dnd from root, when the comment dialogue comes up select the “Recursive” check box. Then all of the sub-dirs will be included.

Intermittent .Net Errors

“ … If you run Index Server (Cisvc.exe), then Index Server may rescan the Temporary ASP.NET Files directory while it requests a Microsoft ASP.NET page. Cisvc.exe then holds a lock on the Temporary ASP.NET Files directory for one to five minutes. The length of time of the lock depends on the size of the directory that causes the Aspnet_wp.exeprocess (or W3wp.exe process for applications that run on Microsoft Internet Information Services [IIS] 6.0) to not load the particular DLL. …”;en-us;329065

FYI - Insert From SP Example

USE ...


SELECT clientID, Nm FROM client


CREATE TABLE #foos (clientID INT, Nm VARCHAR (255))


INSERT #foos (clientID, Nm)
EXEC foobar


-- DROP TABLE #foos

Web.Config vs. Ap.Config Findings

Goal: when are changes to config file picked up automagically?

∆ Web.Config (a) ∆ App.Config (b)

Simple KVP∆
(a) Picked up
(b) Not picked/up

∆ Web.config
(a) appSettings file value Picked up
(b) (hot swappable)

Recycle Ap Pool
(a) Picked up
(b) Picked up

Whack VB IDE Hostile Takeover of Focus

Tools/Options/Editor Uncheck "Auto Syntax Check"

VSxxxx 2005 Visual Studio Can't use IE to debug with VSxxxx (

Check hosts file for localhost entry (lmhosts did not have entry)


Bad (in my case): localhost

Good: localhost

Or just delete the line and let it default to the loopback address

VSxxxx 2003 Visual Studio Tips for Ambiguous Errors

Tips for ambiguous errors

Reference Issues - can not be found
P: C:\Inetpub\ApName\list.aspx.cs(26): The type or namespace name 'ToolBarControl' could not be found (are you missing a using directive or an assembly reference?)
A: Remove and re-add the references

Server Application Unavailable

P: The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request. Administrator Note: An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur.
A: Are you running locally when the ap needs to run in the McCann domain? (i.e. accessing a web service

Q.) Not a valid solution/project file

A.) Make sure you are using VS 2003 (and double check the site is using 1.1)

Q.) Messed up paths for solution after you open projects

A.) Create a new solution, importing the projects from $/dir/ApplicationName

Q.) Error: “Machine to Application” ('MachineToApplication')

A.) Make sure that the Ap directory under root is configured as an application

Q.) Error: “The 'type' attribute must be set to a valid type name. (C:\Inetpub\ApName\web.config line 241)“ when AP tries to invoke the web service

A.) Missing DLL – try Microsoft.Web.Services2.dll” to the bin directory and other projects in the solution ref it

Q.) Error: The type or namespace name 'SomeRef' could not be found (are you missing a using directive or an assembly reference

A.) Remove and re-add the project reference for 'SomeRef’ to project

Q.) Error: The Type Or Namespace Name 'SomeRef’ cannot be found

A.) Make sure that the project SubName is in the solution, build it, in add a reference to its output for ParentProj

Q.) Error: The type or namespace name 'IISPWCHGLib' cannot be found

A.) Add reference to inter-op component Interop.IISPWCHGLib.dll.

Q.) Error: The type or namespace name ADSSECURITYLib cannot be found

A.) Add reference to inter-op component Interop.ADSSECURITYLib.dll

Q.) Error: Object reference not set to an instance of an object
1. Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:
if(ApPart.HasRight(Session,"Full Control") || Session["Role"].ToString() == " Administrator") {…

A.) Make sure that there is a copy of Microsoft.Web.Services2 in the bin directory for Ap (even if the reference is included in the project it appears not to be included in the project. Alternatively register this file in the GAC.)

B.) Make sure that “Allow Anonymous Access” is turned off @ the site level for the web site. [Website] [Properties] [Directory Security] [Edit] [Authentication Methods] uncheck [“Enable anonymous access”]

Q.) Error: A project of type class library cannot be started directly

A.) Set Ap as startup project and select a page (say, mgmt\addEmail.apsx) as the start page

Q.) Unable to open ApWebService

A.) Check the config (web.config & Ap.config) settings for the WS against a working version (say stage)

Q.) No error output, cannot debug

A.) Change web.config values for detailed errors and trace enabled to “true”

Q.) ICSharpCode.SharpZipLib

A.) may be required for some projects. (see $/ApName/Ancillary)

Q.) WSE 2

A.) Requires Web Services Enhancements 2.0

Q.) module 'Session' is : An error occurred during the processing of a configuration file required to service this request added again – The module session is already in the application

A.) cscript.exe adsutil.vbs SET /W3SVC/UploadReadAheadSize 512000

B.) Reboot

Q.) FPSE – Front Page Server Extensions

A.) Not needed

Q.) ASP.Net on local machine …

A.) Make sure aspnet (local machine) has access to c:\windows\temp\ per

Q.) DLL defined multiple places (also – the type attribute must be set to a valid name)

A.) – Erase all content (project output) from the bin directory

B.) “The problem is that you may have other assemblies .i.e. dlls resulting form previous compiles.
You may have renamed your assemblies and thus you may have several name spaces visible.
The .NET framework cannot tell which namespace you are referring to in your \bin directory.
By deleting the offending .dlls (previous named assemblies) you will no longer get this error”

Q.) ASP .Net Version (1.0)

A.) Your IIS directory maybe set to 2.0 – change it to 1.1

Q.) Other & possibly “The remote name could not be resolved”

A.) May have a different hosts file that may/will cause issues trying to connect to remote servers via NetBios vs. IP address.

Q.) The type or namespace name 'ToolBarControl' could not be found (are you missing a using directive or an assembly reference?)

A.) Remove (delete) and re-add the project references. Also verify that the reference paths are for your local machine and not the values retrieved from VSS

Q.) In order to add this reference … ReferencePath property

A.) Say “Yes”

Q.) Error: “web application you are attempting to access on this web server is currently unavailable. Please hit the Refresh” or “Internal Server Error”

A.) Double check IIS set to 1.1, Reboot your machine

Q.) Deployment or “Secure Channel Support”

A.) To deploy I deployed to a local drive (only required files), then shared a dir on the Stage machine, copied the site output with xcopy, undid the share and worked remotely

Q.) Deployment & type attribute must be set to a valid type name.

A.) Use pre-existing stage config files

B.) Copied Microsoft.Web.Services2.dll to bin

Q.) SELECT permission denied on object 'ASPStateTempApplications' (SQL Session State)

A.) Need to enable SQL Server Session State for this login on this database

If server is already configured for ss session state, add that (your) user as dbo for the [ASPState] db and [db_datareader] and [db_datawriter] for [tempDB]

SSRS 3 How to export a report

How to export a report ... navigate to report - [Properties] [Edit] [Save

SSRS2 Faster SSRS Performance


If you RDC to the actual server to make changes (via http) the ui is about twice as fast (makes sense if you think about

SSRS User does not have rights / permissions to view report properties

Joe: I'm having problems granting permissions to an AD group in ssrs, namely even though they are in there (the group "admins", and the group is in ssrs) and all the ssrs roles are attributed to the group members of the group can not access report properties

Sal: I think, cause I have seen similar things they have to be added to the top level and then revoked from the other folders

Joe: k- on the "Home" level?

Sal: yes, home, using the web app

: )

SSPI Cannot generate SSPI context

Cannot connect to sql server – try ip vs net-bios and vice versa

Verisign Cert Process


Add user account (or yourself) to the local machine - Computer Management - Local Users and Groups - Groups

C:\>runas /profile /user:whoopie\my.serviceAccount "c:\winnt\notepad.exe"


a.) Better to use full path to actual executable

b.) In Local Security Settings \ User Rights Management, a 'deny' property overrides an 'allow' property. So, if whoopie\my.serviceAccount is in 'Administrators' & 'Administrators' have "Allow to log on ..." but whoopie\my.serviceAccount is also in group 'Foobar' and 'Foobar' has "Deny log on ..." then whoopie\my.serviceAccount will not be able to log on even though the 'Administrators' group is higher than the 'Foobar' group.


RDC - Send CTRL-ALT-Delete (Control) - CTRL-ALT-End

RDC3 See other people connected to a box (via RDC

Use "Terminal Services Manager" - if all connections are taken up see:

RDC2 Shortcut - How to create icon to launch RDC to specific computer

Launch RDC to specific computer

C:\WINDOWS\system32>mstsc /v:

RDC1 How to get in to RDC when all the connections are used

RDC1 How to get in to RDC when all the connections are used up. Remote Desktop max connection exceeded. Cannot login anymore to servers.

How to get in to RDC when all the connections are used up...

"... Go to Run and issue "mstsc /console" command. This will launch the same old Remote Desktop client you use every day. But when you will connect to remote desktops, it will connect you in Console Mode. Console Mode means connecting to the server as if you are right in front of the server and using the server's keyboard and mouse. Only one person can be connected in console mode at a time. Once you get into the console mode, it shows you the regular Windows GUI. There's nothing different about it. You can launch "Terminal Service Manager" and see the disconnected sessions and boot them out...”

M$ Office 2007 Shortcut Keys

The new equivalent of [F3] == [CTRL] [ALT] [Y] == [CTRL] [Page (Down/Up)] (aka find next w/o a dialogue box)

NetMon2 Location - How to install

1. Open the Control Panel.

2. Click Add or Remove Programs.

3. Click Add/Remove Windows Components to open the Windows Components Wizard.

4. Select Management and Monitoring Tools. Click Details.

5. Check Network Monitor Tools, then click OK.

6. Click Next. If prompted for additional files, insert the installation CD.

7. At the end of the installation, click Finish.,289483,sid68_gci1248316,00.html

Network Monitor - Net Mon - Network Monitor tool - no data captured

Network Monitor
(aka netmon, Microsoft Network Monitor)

If you start NetMon and it does not gather any data make sure that you choose the correct network. [Tools] [Networks] [Local Computer] [Local Area Connection] If you just select [Local Computer] you may not record anything. Good article:

MOSS1 Sharepoint 2007 Training Videos

MOSS1 Sharepoint 2007 Training Videos

MMC1 Launch mmc console for AD w/ specific domain

Launch mmc console for AD w/ specific domain

c:>dsa.msc /

Jing Link to video screen capture tool


JavaScript1 Debug Debugging JavaScript

Debugging client JavaScript in VS 2005

Internationalization Globalization HTML ASP Special Characters Non-US ASCII codes for characters

Special characters

IIS2 Reregister .Net versions 1.1, 2.0

To re-register ASP.NET for IIS:

.Net 1.1: C:\Windows\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -i -enable

.Net 2.0: C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i -enable

.Net 3.0: C:\Windows\Microsoft.NET\Framework\v3.0\aspnet_regiis.exe -i -enable

IIS Log File Location

IIS - website - properties - "web site" tab - "Active Log Format" Properties button - get log file name.

C:\WINDOWS\system32\LogFiles - match log file name to folder, find most recent

Changing the Hosts file to enable NetBIOS name resolution (vs ip)

Copy new Hosts files (LMHost and Host) to %System Root%\system32\drivers\etc\

Cmd exec nbtstat -R

Cmd exec ipconfig /flushdns

Works for SQL, RDC and the file system (i.e. \\net-biosname\c$ vs. \\ip\c$ )

Find in Files not working (VS 2003)

Find in Files not working

"No files were found to look in.Find was stopped in progress." in Visual Studio 2003
It also deserves a nomination in the problem solving category Spin around on your chair 3 times, clap your hands twice and then press... because the solution is to press Control + Scroll Lock and all is fixed. press... because the solution is to press Control + Scroll Lock and all is fixed.

AD Abbreviations Active Directory Attribute WinNT property LDAP property

Names for Objects in Active Directory
One of the biggest confusions with Active Directory is the many “names” that can be used to refer to or describe an object. Most of these “names” are attributes (or properties) of the object. There is even a property method called “Name”. A Property Method is actually a method (a function) that calculates a value from other properties.

Note that the terms “attribute” and “property” are interchangeable. The name of a property or attribute is like the name of a variable. The actual value of the property can be assigned by the network administrator, or sometimes by the system.

Some of the confusion arises because the same attribute can have a different name depending on the provider used. Even worse is that sometimes the same attribute name can refer to a different attribute, depending on the provider. The following table attempts to clarify the situation.

The “Name” property of the WinNT provider is sometimes called the “NT Name”, because it is the name used in NT networks. The WinNT “Name” property of a user object is the pre-Windows 2000 logon name. The LDAP provider calls this attribute “sAMAccountName”. The value can be the same as the value assigned to the LDAP “cn” attribute, but it does not have to be. This can be a major source of confusion. You cannot retrieve the “cn” attribute with the WinNT provider.

The “Name” property method of the LDAP provider is the same as the “cn” property, but with the string “cn=” appended in front. For example, if cn = “TestUser”, then Name = “cn=TestUser”. The "Name" property method returns the Relative Distinguished Name (RDN) of the object.

The same attribute called “FullName” using the WinNT provider is called “displayName” using LDAP. Many of the other attributes used to identify users are only exposed by the LDAP provider.

Both providers expose an “AdsPath” attribute, but this is actually a “Property Method”. It is the binding string used to bind to the object with the provider. The LDAP provider also exposes a “distinguishedName” attribute. It is the same as “AdsPath”, but without the provider moniker (“LDAP://”) in the string. The “distinguishedName” property of an object might be something like “cn=TestUser,ou=Sales,dc=MyDomain,dc=com”. It uniquely specifies the object in Active Directory. It includes the Relative Distinguished Name of the object, plus the full path to the container holding the object in Active Directory.

The “userPrincipalName” is an alternative name for the user to logon with. It is in the form “LogonName@DNSDomain”. For example, it could be “Joe”. This attribute is not always assigned a value in Active Directory.

The only attributes in the table above that are mandatory are “SAM-Account-Name” and “Common-Name”. If a user object is created with the LDAP provider, values must be specified for both “cn” and “sAMAccountName”. If a user object is created with the WinNT provider, only the “Name” attribute is specified (“SAM-Account-Name”), but “Common Name” is automatically assigned to the same value. If a user object is created in the “Active Directory Users and Computers” MMC, the names default as follows. You specify the “First Name”, “Initials”, and “Last Name” of the user (the “givenName”, “initials”, and “sn” attributes). The field labeled “Full Name” defaults to be . . This string is assigned to the “cn” attribute (Common Name). You are allowed to overwrite the default. The fact that the cn attribute is referred to as “Full Name” is another source of confusion. In the “New Object – user” dialog you are also required to specify a “User logon name”. This, in combination with the DNS domain name, becomes the “userPrincipalName”. Finally, As you key in “User logon name”, the field “pre-Windows 2000 logon name” is filled in for you with the first 20 characters of “User logon name”. This becomes the “sAMAccountName” attribute.

The full NT name of an Active Directory object is in the form “NetBIOSDomain\sAMAccountName”. An example could be:


The full LDAP name of the same object could be specified by:


As you can see, the “sAMAccountName” attribute does not have to be the same as the “cn” attribute. In addition, the DNS domain name ( above) does not have to match the NetBIOS domain name (MyDomain above). This can make “finding” objects in Active Directory difficult. Fortunately, the NameTranslate object is generally available to convert names between these two forms.

It should be noted that the sAMAccountName attribute of any object must be unique in the domain. The userPrincipalName must be unique in the forest. However, the cn attribute (common name) must only be unique in the container or organizational unit. There can be several objects with the same cn, as long as they are in different containers. Note, however, that the distinguishedName will always be unique in the forest.

A final concept to discuss is the relative distinguished name, abbreviated RDN. For a user object, this is the common name (cn) attribute. The Name property method returns the RDN. The RDN of any object is the first part of the distinguishedName, abbreviated DN, of the object. For example, if the DN of a computer object is:


Then, the RDN is “cn=Minnesota”.

A few naming abbreviations:

cn Common Name
ou Organizational Unit
dc Domain Component
dn Distinguished Name
rdn Relative Distinguished Name
upn User Principal Name


ADSI linked server needed to run/connect as a network service account

" ... This was quite an old post. But I'll just confirm that the issue is probably due to the service account that MSSQLSERVER service runs under needs to have domain access to query ADSI. Use a domain account to run the service and you should be fine, see info here: ..."

Other ...

Check that you have (sql) rights ...

Check entries in the hosts and lmhosts files

Currently working ADSI query

'SELECT givenName, SN, displayName, mail, sAMAccountName,Department, Division, EmployeeId
FROM ''LDAP://serverwithfulldomain/baseDN''
WHERE objectCategory = ''Person'' AND
objectClass = ''user''')
Fully Qualified Name



(noun, intransitive) : The act or state of being held responsible for performing activities of which you are not aware and for which the instructions are not forthcoming from those aware of the activities which are to take place