How to connect to SQL 2005 from inside SQL 2008 Management Studio

I recently ran into a problem where I needed to connect to SQL 2005 from inside SQL 2008 Management Studio.

I have SQL 2008 installed on my machine and I run my sql scripts against the production environment which is hosted by my ISP.
Although, the configuration is pretty straight-forward, however, if not done often, it can turn into oblivion.
This blog post is mainly a reminder to me in case I re-image my hard-drive and have to repeat the process.
Here are the following steps:

- Inside SQL 2008 Management Studio, highlight Database(s) node. You will notice on the right hand pane, there are five columns, namely Name, Policy Health State, Recovery Model, Compatibility Level and Owner.

- Highlight the ‘Name’ column and right click on it, uncheck Collation.

- Now, try to reconnect or simply refresh.

- You should see all available data bases on the shared server.


Obi />

How to export Telerik's RAD Editor to MS Word

I am currently working with Telerik’s RAD Editor server control for ASP.Net.
Needless to say, the control provides a plethora of features for styling, formatting and such.

For all intents and purposes it’s a WYSIWIG tool and you can do practically anything what you can with MS Word. All said and done, however, it does not provide any out-of-the-box functionality to convert the editor's content to MS Word.

What you can do though is to save the editor content as an .html file, read the entire content into a string and open it in MS Word. If you want to edit the .html content, you can even go as far as doing a simple string replacement.

Here’s the code that does just that…
Private folderPath As String = "C:/Report/"
Private template As String = "MyMemo.DOT"

Protected Sub SaveRADContentAsHTML()
Dim WordApp = CreateObject("word.application")
Dim WordDoc = WordApp.Documents.Open(Server.MapPath(folderPath & template))
WordApp.Application.Visible = False
Dim wordDocPath As String = Server.MapPath(folderPath)
If Not File.Exists(Server.MapPath(folderPath & " MyMemo.html")) Then
WordDoc.SaveAs(wordDocPath & "MyMemo.html")
End If


WordDoc = Nothing
WordApp = Nothing
Catch ex As Exception
Throw ex
End Try
End Sub

Private Sub btnReplaceWord_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReplaceWord.Click
Dim wordDocPath As String = Server.MapPath(folderPath)
Dim inputText As String = String.Empty
Dim sTemp As String = String.Empty
inputText = ReadFile(wordDocPath & "MyMemo.html")
sTemp = inputText.Replace("Purpose~1", radEditor1.Content) 'Please note the string "Purpose~1" is used as a marker for string replacement
Using sw As New StreamWriter(Server.MapPath(folderPath & "Test1.html"))
End Using

Catch ex As Exception
Throw ex
End Try
End Sub

Protected Function ReadFile(ByVal myFilePath As String) As String
If Not File.Exists(myFilePath) Then
Return String.Empty
End If

Using sr As New StreamReader(myFilePath)
Return sr.ReadToEnd()
End Using

Catch ex As Exception
Throw ex
End Try
End Function

Talk on LINQ to SQL Stored Procedures

On June 17th, I gave a talk on LINQ TO SQL Stored Procedures at Manulife.

Below, please see a link to the sample code that I used for demonstration:


Obi />

AJAX - Fileupload.HasRows returns false???

I have recently jumped on the AJAX bandwagon and am frantically trying to AJAX enable all my web pages through the use of asynchronous partial-page updates.
A typical design pattern of an ASP.NET AJAX application involves it consuming web services directly from the client without requiring postbacks to the web server. Not only do postbacks slow down an application, but they also complicate the application design, implementation, and deployment.
AJAX is so addictive and such a compelling technology that once you have gotten the hang of it, it is hard to refrain from using it.

However, all said and done, there are some pitfalls that one ought to be aware of.
This blog post is certainly not intended for what AJAX can or can’t do, but if you are looking to convert your web page and make them AJAX enabled, there are a few things you have got to keep in mind just in case you are stuck.

I had a web page with input controls on a panel all of which were wired to the validator controls. In addition, I also had a FileUpload control.

Prior to AJAX enabling the web page, everything was fine and dandy, but the minute I wrapped the asp panel in an Update Panel, everything worked but the FileUpload. In that, the control (FileUpload) did not detect the file name and returned an empty string when checking for FileUpload.HasFile.

The solution to the problem was not difficult either.
In the markup, essentially all that was missing was the PostBackTrigger with the ControlID="btnSubmit".

So essentially, all that is happening now is that we are forcing a post back on the click event of the button while everything else happens asynchronously using the Update Panel. So, when the user presses the button, the page gets refreshed and filename is detected.

My next area of interest is JavaScript Object Notation (JSON). This is just another piece of functionality that is part of the AJAX Extension toolkit typically used for serializing and deserializing data. It is somewhat akin to XML/SOAP, except that JSON is a text-based data interchange format which delivers a more consistent experience due to the implementation differences of XML/SOAP by the various browsers.


Obi />

LINQ TO SQL Vs. Lambda Expressions

It is amazing how much you can achieve with Lambda expressions using a single line of code vs. several lines of Linq to Sql. Although, linq to sql is a better choice over traditional CRUD operations using sql and the like. Here's how... Create a new console application project in VS.Net 2008 and import the following name spaces in the module:
Imports System.Collections
Imports System.Linq

Let's declare an array of string as below:
Dim Provinces As String() = {"Ontario", "New Brunswick", "British Columbia", "PEI", "Quebec", "Manitoba", "Alberta", "Northern Territories"}

Using LINQ to SQL, iterate through the array list and write the result to a console as below:
Dim oProvince = From s In Provinces _
Where (s.StartsWith("N")) _
Select s

For Each province In oProvince


See the number of lines it took to display the provinces beginning with "N"!!!
With Lambda expressions, all of this can be achieved in a single line of code. See below:

For Each prov In Provinces.Where(Function(p) p.StartsWith("N"))


Lambda expressions are very powerful which take anonymous delegates to give you the desired result.
While I use LINQ TO SQL where necessary but don't miss a chance when it comes to Lambda expression usage.

Obi />

Tech Days is here...

TechDays is happening in Toronto.

Tech Days is a technology training conference for Canadian IT professionals and developers.

Although, it is a national event and will be held in all major cities of Canada with a single and two day workshops, however, it will be a two day event in Toronto.

I am taking some time off work to attend this event. With five tracks from Windows, Web, Data Management etc., my main emphasis will be on the Web and Windows tracks with topics like AJAX for ASP.Net, Silverlight, WPF and MVC framework.

I think, it is a compelling event with early-bird fee of just $249 which also includes breakfast and lunch.

For further information or to register, click the url below:


Obi />

IE 7.0 Freezes

Recently what appeared to a be a problem with IE 7.0 on my Lenovo T61p drove me up the wall. Every time, I would open a second instance of the browser, it would not only freeze the browser but also all the active windows on my machine!!! I later found out that it was the "Shockwave Flash Object" by Adobe that was the culprit. So overcome this otherwise annoying problem, in IE 7.0 I went to Tools - Manage Add-ons - Enable or Disable Add-ons and disabled the "Shockwave Flash Object" and voila... This action seems to have fixed my problem wherein I can now have multiple instances of IE or for that matter have multiple tab pages in a single instance of IE 7.0.

Obi Oberoi

Software in 2008

Here are some of the predictions of what future holds for the industry software in 2008.

1. User Experience Reaches the Enterprise. In 2008 we will see several major enterprises start efforts to build UX centric applications that increase worker productivity, reduced transaction costs and increase pull through as the UX meme of the consumer facing world leaks into the enterprise. The days of the battleship gray, forms of data application as the king of the enterprise are numbered because of an imperative towards richer visualization of complex and interconnected data. While there will always be a need for the traditional sort of application, by the end of 2008, it is no longer the only element of the corporate landscape. 

2. Testability Becomes a Requirement for Software Development Frameworks. No longer satisfied with simple reductions in costs for initial development, a growing community demand frameworks and tools that facilitate sustainable and agile practices. 2008 is the year that frameworks and tools take notice and start to deliver solutions that are testable out of the box. Technologies such as Test Driven Development, MVC/MVP patterns, and frameworks that support mocking become mainstream. After seeing this year’s cool demos at software development industry conferences a common question will be: “...And how do you test that?” Let’s hope the presenters have an answer.

3. The Companion Applications Become Practical. While RIA and AJAX application categories continue to grow, many consumer facing web applications and enterprise applications developers realize there is a need for desktop exploitive applications as well as reach web applications that work everywhere. What meaningful application wouldn’t benefit from a pairing like that of Outlook and Outlook Web Access? In the past it has been prohibitively expensive to build these applications, but with the circa 2008 technology such as .NET Framework 3.5 and Silverlight, it is finally becoming practical to have a single codebase that fully exploits the desktop and offers a rich web experience.


Obi Oberoi


Definition of Interoperability

What does the term 'interoperability' really mean? What does it mean to 'interoperate' or be 'interoperable' when designing solutions? A number of definitions are available depending upon whom you speak to or where you search. Some define interoperability in terms of relationships; others have a much more specific view based on the technology that they are describing.

To define this term, as per Simon Guest, there is a three-part explanation: one formal, one pictorial, and one comparitive.

1. Formal: Interoperability enables communication, data exchange, or program execution among various systems in a way that requires the user to have little or no awareness of the underlying operations of those systems. Interoperability is about connecting and building applications that work with each other to such an extent that the presentation to the user is seamless.

2. Pictorial: When describing interoperability, think of it as making reference to a popular lake-dwelling species, the duck. As a duck is seen swimming across a lake, only the top half of the duck looks very serene. The duck appears to glide across the lake with little or no effort. Despite this calm exterior, the duck’s legs are frantically kicking in all directions to get to the other side of the lake. Such is the way of interoperability. A well –designed solution that interoperates among many diverse systems should appear “calm and serene” to the user – the user should have no awareness that a click of a button or a switch of a page might create many calls to various systems throughout the enterprise, somewhat akin to the frantically kicking legs of our feathered friend.

3. Comparative: Comparative draws upon the previous two but offers a slightly different slant which is the following:

• Migration: Opportunities exist in the migration space. Customers do have code that can benefit from running on the .Net framework, and some of this code already exists within J2EE applications today.

• Portability and Interoperability: Portability is the notion of running a single component or piece of code on platforms based on multiple implementations from various vendors. The point isn’t to detail the sustainability of either the Java or the .Net platform for developing applications. The success lies in the operability between the two platforms.

• Reuse of existing systems: Most established companies have a number of legacy systems. The term legacy is meant technology that’s not being actively developed upon today. For example, a system located in the data center that’s still in production but no longer offers a strategic advantage to the company is a legacy system. A plan to move these systems to a new platform might be a longer-term strategy. A solution that has the ability to interoperate with these systems has the potential to extend the life of these systems and more importantly, the knowledge of the developers who work with them.

• Delivery based on technical merit: Designing an architecture that can enable interoperability promotes the selection of platforms based on technical merit. One could argue that every platform and technology—whether it’s .Net, J2EE, or anything else – has its own merits for deployment. This could be maturity, reliability, scalability, security, technical advancement, and so forth. An approach to developing applications and services that have the ability to interoperate with one another allows platforms to be selected based on their merit and applicability to the job, allowing greater choice regardless of the vendor.

• Pilot for adoption: When organizations want to deploy a new technology such as the .net framework, it’s rare that they simply rip and replace an entire application or system. In many cases, a replacement is normally triggered by a pilot, or proof-of-concept, project. Such a pilot tends to be a short-term project with an aim to prove that the technology can work well with existing systems and applications. The ability for this pilot or proof-of-concept project to interoperate with existing production systems is imperative, and in many cases, can often determine its success.

• Migrations: Even if a system will be replaced or updated, it’s rare to find a case where this can be done with a single “flick of a switch” – many migrations have to be well planned and carefully executed, and often involve moving an application a few parts at a time. This way of dividing a system for migration purposes often creates a demand for interoperability (because some parts that have been migrated still might need to communicate with others that have not).

Obi Oberoi

ASP.Net Tutorial - A way to go!!!

What a better way to learn ASP.Net than reading the tutorial below...

New Features in ASP.NET 2.0

ASP.NET 2.0 offers some of the following new features:

  • Master Pages, Themes and Web Parts

  • Security controls standardized

  • Standard controls for navigation

  • Personalization, roles and internationalization services

  • Simpler and better data access controls

  • Complete support for XML standards

  • Better compilation and deployment

  • Better Site Management

  • New and improved development tools

Let's discuss these new features in detail:

Master Pages

ASP.NET didn't offer a way to have a consistent look and feel for the complete web site.

ASP.NET 2.0 solved this problem by introducing master pages. A master page is a template for other pages, with shared layout and functionality. The master page defines placeholders for content pages. The result page is a combination (merge) of the master page and the content page. More about master pages read in Master Pages in ASP.NET 2.0 tutorial


To give a customized look to the web applications, ASP.NET 2.0 came up with the themes/skins feature (more about this feature you can find in Themes and Skins in ASP.NET 2.0 tutorial).

ASP.NET 2.0 aimed to achieve the following design goals:

  • Simplify to customize the appearance of a site

  • Allow themes to be applied to controls, pages, and entire sites

  • Allowing the customization of all visual elements

Web Parts

ASP.NET 2.0 Web Parts provide a consistent look for a site, while still allowing user customization of style and content (more in Web Parts in ASP.NET tutorial).

New controls:

  • Zone controls - areas on a page where the content is consistent

  • Web part controls - content areas for each zone


ASP.NET 2.0 introduces built-in navigation controls (more in Web Site Navigation in ASP.NET 2.0 tutorial)

  • Site Maps

  • Dynamic HTML menus

  • Tree Views


Security plays a key role in application development. So the confidential and personal information need to be protected (read more on Security Features in ASP.NET 2.0).

In ASP.NET 2.0 the following controls has been added:

  • A Login control, which provides login functionality

  • A LoginStatus control, to control the login status

  • A LoginName control to display the current user name

  • A LoginView control, to provide different views depending on login status

  • A CreateUser wizard, to allow creation of user accounts

  • A PasswordRecovery control, to provide the "I forgot my password" functionality

Roles and Personalization

Internet communities are gaining popularity. ASP.NET 2.0 has personalization features for storing user details. This caters to an easy way to customize user (and user group) properties (more about user management read in User registration and authentication for an ASP.NET 2.0 tutorial).


To cater and reach out to a large audience is important and requires reaching people with different languages. So to handle this, ASP.NET 2.0 introduces an improved support for multiple languages (read more in Building Multilingual Web Sites with ASP.NET tutorial).

Data Access

There are many data driven web sites that use databases or XML files as data sources. With ASP.NET this involved code, and often the same code had to be used over and over in different web pages.

A key goal of ASP.NET 2.0 was to ease the use of data sources and eliminate this redundancy. ASP.NET 2.0 has a whole new data controls, removing much of the need for programming and in-depth knowledge of data connections. Read more in Data Source Controls in ASP.NET 2.0 and DataSet and DataAdapter in ASP.NET 2.0 tutorials

Mobility Support

Often with Mobile devices is a problem arises when it comes to screen size and display capabilities. In ASP.NET, the Microsoft Mobile Internet Toolkit (MMIT) is used for such purposes. But In ASP.NET 2.0, MMIT is no longer needed because mobile support is built into all controls.


In ASP.NET 2.0, following new controls for image handling have been included:

  • The ImageMap control - image map support

  • The DynamicImage control - image support for different browsers

These controls are important for better image display on mobile devices, like hand-held computers and cell phones.

Automatic Compilation

ASP.NET 2.0 supports automatic compilation. The first run will compile all files within a directory, including support for WSDL, and XSD files.

Compiled Deployment (Installation) and Source Protection

ASP.NET 2.0 also provides pre-compilation. A complete web site can be pre-compiled. This gives an easy way to deploy (upload to a server) compiled applications, and this protects the source code as only compiled files are deployed.

Site Management

ASP.NET 2.0 introduces three new features for web site configuration and management:

  • New local management console

  • New programmable management functions (API)

  • New web-based management tool

Development Tools

Along with ASP.NET, Project and design features were released in Visual Studio.NET keeping in mind the need of corporate developers. With ASP.NET 2.0, Visual Studio 2005 was released.

Visual Studio 2005's key design features include:

  • Support for the features described above

  • Upload files from anywhere (FTP, File System, Front Page...)

  • No project files, allowing code to be manipulated outside Visual Studio

  • Integrated Web Site Administration Tool

  • No "build" step - ability to compile on first run

For non-corporate developers who cannot access Visual Studio.NET, ASP.NET introduces a new and free tool called Visual Web Developer. More about this free tool read in Introduction to Visual Web Developer 2005 - Express Edition tutorial.




MSDN Real Development Reloaded Tour 2007

Hi Folks,

Microsoft Canada has just announced the upcoming realDevelopment 2007 Tour.

"This tour is all about Web development and how to make better use of
current technologies like AJAX and Visual Studio 2005 in your projects. If
you are a web developer you don't want to miss this."

The Toronto event will be held on Tuesday, October 30 at the Metro Toronto
Convention Centre from 8:00am to noon. For more details and to register,
please visit:




Virtual PC 2007 for download

Virtual PC 2007 was released in final form for download early this year.  You can read more about Virtual PC 2007, and download it, from the newly updated Virtual PC website:

Some key features of Virtual PC 2007 include:

  • Support for x64 Windows as a host operating system
  • Support for hardware virtualization support
  • Support for Windows Vista as a guest and host operating system 
  • Support for PXE network booting of virtual machines
  • Support for the use of fullscreen virtual machines on multi-monitor systems (VM still stays on just one monitor though)



What's with IIS and Apache

How does IIS7 stack up against Apache? Bill Staples, who runs the server products within the Developer Division – Web Server, Media Server and Commerce Server recently wrote a great blog that talks about IIS versus Apache. It is a very well written piece and for those of you interested in understanding what's going on in the web server space and how IIS compares against other offerings, this is a good read.


Obi Oberoi

Seminar on SOA

Next week, I am attending a breakfast seminar on bridging Service Oriented Architecture organized by Object Sharp Consulting. Thanks to Rob Windsor who informed me about it.

I am currently writing a thesis on 'Interoperability between Disparate Systems' . I am sure this seminar will feed some ideas to facilitate in polishing up my thesis.


Obi Oberoi


Learning VB.Net online

This how-to video series is dedicated to getting Visual Basic developers productive on areas of data-based Windows Application development. The series starts with the basics of database development with SQL-Server 2005 Express then walks through the details of connecting to and querying databases, and Windows Forms development basics using the built-in designers in Visual Basic 2005.

This series is aimed at VB.NET Winforms and database beginners...Enjoy the series!