Sunday 13 October 2013

Visual Studio : Creation of the virtual directory http://localhost failed


When creating a copy of an application from Visual Source Safe, sometimes developers get the following error message :
The local IIS URL http://localhost/ specified for Web project DemoWebsite has not been configured. In order to open this project the virtual directory needs to be configured. Would you like to create the virtual directory now?
After clicking ‘Yes’, a new error message will be displayed:
Creation of the virtual directory http://localhost/ failed with the error: The URL ‘http://localhost/’ is already mapped to a different folder location.
All the projects will be loaded expect for a project which states unavailable and by right-clicking the project and selecting the option of editing the file with an extension of either .csproj or .vbproj.
In the file, find <iisurl> tag with localhost.( <iisurl>http://localhost/</iisurl&gt;) Change the tag details to your application name (<iisurl>http://localhost/yourapp</iisurl&gt;). Reload the project and you should be able to load the project now.

Monday 3 June 2013

ASP/ASP.NET Session Timeout – How Do I Change It!?
20 minutes… 20 minutes… 20 minutes… Does this sound familiar?
You’re trying something simple, or so you thought, and increasing the session timeout of your website, but it doesn’t appear to be having any effect.
ASP.NET
Usually, the first and easiest thing to do is just change the configuration/system.web/sessionState@timeout value to something like “90″.  This should mean that you’d like your users’ sessions to be persisted until a 90 minute window of idle time has elapsed.
web.config
<configuration>
  <system.web>
  ...
   <sessionState timeout="90" />
  ...
 </system.web>
</configuration>

So, what do you do now? You go ahead and make sure it works… but wait… it still appears to be timing out after 20 minutes.
This doesn’t make any sense, it explicitly says that the session timeout should be exactly 90 minutes.
There’s a couple of issues that are tied together here:
·         The application pool’s worker process default idle timeout is also set to 20 minutes
·         The default mode of storing session state is in the IIS process

Application Pool Idle Timeout
The settings for the application pool can be found by clicking Properties (IIS 6) or Advanced Settings (IIS 7.5) on the application pool that the application is assigned to.
 
Ensure this value is set to the timeout of your session, at a minimum, to ensure that all sessions persist for the entire session timeout period.
The reason that these two values are dependent on one another is because the session information is actually stored within the worker process of the application pool. That is to say, if the worker process is shutdown or killed for any reason, the session information will be lost.
Session Storage Mode
There are the modes of storing the session information:

  • ·         InProc (or In Process) – Default – Stores session information within the IIS worker process
  • ·         StateServer – Stores session information in a separate process (the ASP.NET state service)
  • ·         SQLServer – Stores session information in a SQL database
The only mode that is vulnerable to losing session information on a worker process is when the state is stored in the worker process. Both StateServer and SQLServer modes are not affected by worker process resets. Likewise, StateServer and SQLServer modes are the only options when it is necessary to share session state across more than a single IIS server.
For more information about these modes, check out MSDN.
ASP
There’s two ways to change the session timeout when you’re dealing with classic ASP.
You can set it at the application level, or programmatically, which means that the value can be different within the application.
Application Level
Since it doesn’t specifically state that the setting is for classic ASP, it may be confusing to know that the value is in: Application Properties -> Configuration… -> Options -> Enable session state.
It’s as simple as updating this value, and the session timeout for your entire classic ASP application is changed!

Programmatically
You can also use modify the Session.Timeout property at runtime to affect the timeout period of the session. One popular location to put this piece of code is in the global.asa file.

global.asa
<script language="VBScript" runat="Server">
Sub Session_OnStart
 Session.Timeout = 90
End Sub

</SCRIPT>

Tuesday 7 May 2013

Quick Reference- Working with Recordsets VBA


Sub testSqlRuns()
    'Purpose:   Open a recordset using ADO.
    Dim rs As New ADODB.recordSet
    Dim cn As New ADODB.Connection
   
    Dim strSQL As String
    Dim strConnString As String
   
    strConnString = "Provider=SQLOLEDB;Data Source=US440;" & _
                  "Initial Catalog=Test;" & _
                  "User Id=user;" & _
                  "Password=pwd;"
                 
    strSQL = "SET NOCOUNT ON;" & vbCrLf & _
            "SELECT TOP 5 * FROM Issue"
   
    cn.Open strConnString
   
    ' record count will be -1 for forward only recordsets
    ' adOpenForwardOnly is default and fastest. You can go through the recordset start to finish once.
    '       Once you reach EOF you can not use the recordset.
    '       Best for when you need to do one pass through the data
    rs.Open strSQL, cn, adOpenForwardOnly
    Debug.Print rs.RecordCount
    rs.Close
    Set rs = Nothing
   
    Set rs = New ADODB.recordSet
    ' You need to specify adUseClient to tell data provider that you are going to be browsing records
    '       on the excel client (vs SQL Server)
    rs.CursorLocation = adUseClient
    ' adOpenStatic takes a snapshot of data as of the time command was run.
    '       Allows parsing recordset any way you want. Will not reflect changes to data,
     '      but this is ok.
    
    rs.Open strSQL, cn, adOpenStatic
    Debug.Print rs.RecordCount
   
    Do While Not rs.EOF
        Debug.Print rs.Index & ";" & rs!issue_name
        rs.MoveNext
    Loop
   
    rs.Close
    Set rs = Nothing
End Sub

Thursday 2 May 2013

Datasets / Report data window vanishes - BIS 2008


You open the project and the window panel for the Report Data containing the parameters and datasets isn't there. I spent a bit of time enabling/disabling toolbars before I found this.
  1. Open a Report solution (or have one open already?)
  2. The menu link is "report data" and it's right at the bottom of the "View" menu.

Report Data at the bottom of the View menu when a report is loaded in the editor

Monday 1 April 2013

MCTS 70-433 Training Material

Data truncated to 255 characters with Excel ODBC driver

When you retrieve external data using the Microsoft Excel 2010 ODBC driver, fields that have more than 255 characters may be truncated to 255 characters.

Your data may be truncated to 255 characters if the first 8 records for the field(s) being truncated contain 255 or fewer characters. The Microsoft Excel ODBC driver will, by default, scan the first 8 rows of your data to determine the type of data in each column. 

Even though you can change the Rows To Scan value in the ODBC Microsoft Excel Setup dialog box to something higher than 8 (but not higher than 16) this value is not being used by Excel. The Excel ODBC driver uses the TypeGuessRows DWORD value of one of the following registry key to determine how many rows to scan in your data:

Please do the following and then try to import data using ADO . This will solve the issue.

1.       Close any programs that are running.
2.       On the Start menu, click Run. Type regedit and click OK.
3.       In the Registry Editor, expand the following key:


  • HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Office\12.0\Access Connectivity Engine\Engines\Excel
  • HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Access Connectivity Engine\Engines\Excel
  •  HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Jet\4.0\Engines\Excel

4.       Select TypeGuessRows and on the Edit menu click Modify.
5.       In the Edit DWORD Value dialog box, click Decimal under Base. Type value 0, for Value data. Click OK and quit the Registry Editor.

NOTE: For performance reasons, setting the TypeGuessRows value to zero (0) is not recommended if your Excel table is very large. When this value is set to zero, Microsoft Excel will scan all records in your table to determine the type of data in each column.

APPLIES TO
  • Microsoft Office Excel 2010
References-  http://support.microsoft.com/kb/189897