Error: Both DataSource and DataSourceID are defined on ‘controlname’. Remove one definition.

Assuming you don’t actually have both a DataSource and DataSourceId defined on the same control, this may actually be a bug.  My situation is Visual Studio 2008, compiling an application for .NET 2.0.  I tested this with both Enterprise Library 2.0 and Enterprise Library 3.1.  For me, I’m trying to hydrate a RadioButtonList from a dataset, which is created from a stored procedure call with a parameter passed.  If I hardcode some values in the sproc and don’t pass the parameter, it all works fine.  But, if I pass the parameter, I get the error.  I have a workaround in mind, and I’ll post it whenI get it done.

I reported this at, with an issue ID = 323454; the title is “Both DataSource and DataSourceID are defined…”.  If you’re having the same problem, log in and vote for this issue–more votes = higher priority.  The text of my report is below:

I’m using VS 2008 (9.0.21022.8 RTM), compiling for the .NET 2.0 framework.

On a web form, I’ve added a RadioButtonList, as below:

<asp:RadioButtonList ID=”rblShippingPlatform” runat=”server” CssClass=”FormFieldsAjax” />

In code behind, I call a function in a CBO in the same project to hydrate the values:

cPub.fillShippingPlatforms(rblShippingPlatform, cPublic.Segment.Lane)

The function in the CBO makes a call to the DAL, which is a shared library added as a project reference:

    Public Sub fillShippingPlatforms(ByVal rblPlatforms As RadioButtonList, ByVal sSegment As String)
        With rblPlatforms
            .DataSource = cDb.GetShippingPlatforms(sSegment)
            .DataValueField = “ShippingPlatformID”
            .DataTextField = “ShippingPlatform”
        End With
    End Sub

The DAL simply executes a stored procedure and returns a dataset:

    Public Function GetShippingPlatforms(ByVal sSegment As String) As DataSet
        dB = DatabaseFactory.CreateDatabase
        cmd = dB.GetStoredProcCommand(“lpGetShippingPlatforms”)

        With dB
            .AddInParameter(cmd, “@Segment”, DbType.String, sSegment)
            Return .ExecuteDataSet(cmd)
        End With

    End Function

There’s nothing fancy here, but when I load the web form, I receive an error stating “Both DataSource and DataSourceID are defined on ‘rblShippingPlatform’. Remove one definition. “.

I can hydrate the RadioButtonList if I adjust the stored procedure and remove the parameter handling.

    Public Function GetShippingPlatforms(ByVal sSegment As String) As DataSet
        dB = DatabaseFactory.CreateDatabase
        Return dB.ExecuteDataSet(CommandType.StoredProcedure, “lpGetShippingPlatforms”)
    End Function

This issue occurs with both the Jan 2006 and May 2007 versions of the Enterprise Library.

Registration Open for Pittsburgh Launch of Visual Studio 2008

Registration is now open for the Pittsburgh launch of Visual Studio 2008, SQL Server 2008 and Windows Server 2008.  The launch is April 14 at the Westin Convention Center–additional details as they become available.

The date seems to have changed–I recall is being April 4 last week, so make sure you schedule the right day to be out of the office.

Register at

Easy SQL to XML with LINQ and Visual Basic 2008

My latest ASP Alliance article has been published:

Easy SQL to XML with LINQ and Visual Basic 2008

In this article, I demonstrate how to create an XML file from a SQL Server 2005 database using LINQ. He provides a detailed explanation of the relevant steps with the help of source code and screenshots captured from Visual Basic 2008 Express Edition. At the end of the article, he also gives a few references where you can learn more regarding the techniques involved with LINQ.

If you’re looking for a super quick intro to using Linq to SQL and Linq to XML using Visual Basic, this might be what you’re looking for.  I’ve added links to a couple other useful references, too.

This is beautiful code

If you’ve ever listened to Hanselminutes, you’ve no doubt heard Scott
mention “code smell” or “pretty code”.  The new language features in VB9,
including LINQ and XML being a native type, make XML generation not only easy,
but beautiful.  Aside from the color scheme, look at how smooth this code
snippet is.

Dim _order As New XElement(<Order>
    <ShipperRef><%= h.UniqueRef %></ShipperRef>
    <UniqueRef><%= IIf(h.CustomerPo <> "", h.CustomerPo, h.JdeNumber) %></UniqueRef>
    <Comments><%= _orderComments %></Comments>
    <OrderType><%= h.OrderType %></OrderType>
    <Workflow><%= h.Workflow %></Workflow>
    <RORRelationship><%= h.RORRelationship %></RORRelationship>
    <Supplier><%= h.SupplierNumber.ToString %></Supplier>
    <Customer><%= h.Customer.ToString %></Customer>
    <FreightBillableParty><%= h.FreightBillableParty %></FreightBillableParty>
    <HAZMAT><%= h.Hazmat %></HAZMAT>
    <GroupAssignment><%= SetGroupAssignment(h.GroupAssignment) %></GroupAssignment>
    <Weight><%= _orderWeight.ToString %></Weight>
    <Volume><%= _orderCube.ToString %></Volume>
    <OrderContact><%= h.PrimaryContactAssignment %></OrderContact>
    <ShipmentContact><%= h.PrimaryContactAssignment %></ShipmentContact>

2008 theme is DesertNights
, and the code was copied with CopySourceAsHtml.

Installfest Tips

Tip: Install one of the Express editions before you go.

Visual Studio 2008 Installfests are going on around the country.  We had ours in Pittsburgh today, and the place was packed.  It was fun just to tinker with a bunch of other developers around.

Most people brought laptops, which means there were varying degrees of success with the installation (usually due to incomplete removal of beta bits).  One of the longest parts of the process is the installation of the .NET 3.5 Framework.

My installation was flawless and quick.  Just after VS 2008 shipped, I installed VB.NET express, which included the lengthy framework installation.  Since I already had he framework, my installation was complete a great deal of time before anyone else’s, and I had time to bang out a quick Linq demo.

In some towns, there are little programming or example contests for swag.  The extra time could do you some good.

Installfest Pittsburgh

December 11, 2-4 pm, or 5-7 pm (two sessions). 

Tuesday, December 11, 2007 (EST) – Visual Studio 2008 Community Launch

location: Microsoft Offices

Join us for the Visual Studio 2008 community launch party at Microsoft!
We’re having 2 sessions: 2-4 pm and 5-7 pm, with lots of giveaways, including
125 full Visual Studio 2008 licenses!

Join the Pittsburgh .NET User’s Group on Tuesday, December 11th for

our Visual Studio 2008 Launch Event.  Danilo “Dani” Diaz, Microsoft

Developer Evangelist for Microsoft’s Mid-Atlantic Region will be our

featured speaker.  Dani will be demonstrating the new features of

Visual Studio 2008 along with the new features of the .NET Framework

3.5.  Bring your laptop as we’ll be providing trial editions of
for you to install and try out new features as Dani discusses them.

We’ll also have a coding competition to see who can utilize the new

VS2008 features the best in creating a killer app; winners of the

local coding competition will be entered into a regional competition

where the stakes (and prizes) definitely increase!  All attendees (up

to a max of 125) will receive, via email, a free license to Visual

Studio 2008 Professional.
Due to the expected turnout for
the event, we will be having two
sessions for our launch event.  Both
will be held at Microsoft’s
offices on the North Shore.  The sessions
will be held from 2-4 PM and
from 5-7 PM on Tuesday, December 11th. 
We’ll also have lots of
give-aways at both events.  So come to the
December .NET User’s Group
on Tuesday, December 11th, and kick your
holidays off to a good start.

Full info and RSVP link at

There is no Unicode byte order mark. Cannot switch to Unicode.

You may receive this error if:

  1. you created a project in a pre-release Visual Studio 2008, and
  2. your project contains DBML files (created by database designer,
    like when using LINQ), and

  3. This is the first time you’re opening the project in VS2008 RTM.

Fortunately, the answer is simple.  In the code view of the DBML file,
you need to change the encoding from utf-16 to utf-8.

Thanks to Julie
Lerman for the solution
.  Some additional information at Converting
web site projects from Visual Studio 2008 Beta 2 to Visual Studio 2008

VS 2008 Installation – So much smoother this time!

You need to get out waaaaayy more if I’m the one telling you Visual Studio
2008 has shipped for MSDN subscribers.  It’s available for download as of
yesterday from the MSDN Subscribers Download.

Kudos to the Visual Studio team this time–uninstillation of beta 2 and
installation of the RTM bits is so much smoother this time.  Not everything
you need to uninstall is removed when you remove beta 2, so you have to go
through the add/remove programs and get the stragglers.  Use the list at for
guidance.  But, some of the names on the list vary slightly (Crystal
Reports 2007 was listed in my Add/Remove as Crystal Reports for Visual Studio
2008), but they’re easy to match up.  Also, some of the items on the list
(e.g., Microsoft .NET Framework 3.5) are removed by the beta 2 uninstaller, so
you may see them in Add/Remove, and get an error when you try to uninstall
them.  They clean up with the next reboot.  Expect 2-3 hours of
uninstallation, manual clean up and reinstallation.

All in all, though, so much better than with VS 2005.