Is SqlDataSource asking for trouble?

One of the new features within ASP.NET Whidbey is a set of DataSource controls.  The controls allow developers to bind data using a declarative syntax within an ASPX page.  Let's take a look at a sample.

<asp:sqldatasource
    id="SqlDataSource1"
    runat="server"
    selectcommand="select customerid, companyname from customers"
    providername="System.Data.OleDb"   
    connectionstring="Provider=SQLOLEDB.1;Integrated Security=SSPI;
Persist Security Info=False;Initial Catalog=Northwind;
Data Source=localhost;Use Procedure for Prepare=1;
Auto Translate=True;Packet Size=4096;Workstation ID=SERVER1;
Use Encryption for Data=False;
Tag with column collation when possible=False">
</asp:sqldatasource>

The above control sets up a connection to a Sql Server database that other controls can now use to populate themselves.  To setup a control to use the SqlDataSource control declared above you set the datasourceid of the control you would like to bind the data to.

<asp:dropdownlist
    id="DropDownList1"
    runat="server"
    datavaluefield="customerid"
    datasourceid="SqlDataSource1"
    datatextfield="companyname"
    autopostback="True">
</asp:dropdownlist>

When I frist saw some examples of the new data source controls I thought they seemed like a decent idea, however, the more I think about the implications of using the controls the more I'm beginning to think they're asking for trouble.  Having the details of data connections interspersed with presentation code is simply not a good idea.  I have a couple buddies who are just learning the .NET ropes and these types of features worry me. 

# re: Is SqlDataSource asking for trouble?

Monday, October 27, 2003 2:42 PM by Thomas Tomiczek    
I have no idea what to say here. I see your reasons for this. I also see the reasons why they do it (which boils down to components not being good enough to interoperate).

Putting the stuff into the &quot;visible area&quot; (controls) was a solution here.

Maybe the price paid was too high.

Frankly, I am not convinced with the new model, either. The ObjectDataSource is another of these hacks - way worse that what we currently have under .NET 1.1 (we means our product). It could have been much better.

Well, lets work with what MS gives us :-)

# re: Is SqlDataSource asking for trouble?

Monday, October 27, 2003 4:11 PM by Frans Bouma    
This isn't a surprise. Every visual studio release offered this kind of crap and they demoed it every time. And each time they learned it was unusable because no-one in their right mind would place a database connection on a webform.

I share the concerns of Thomas about the ObjectDataSource. I read somewhere that it is able to feed data from ANY class / class hierarchy to controls, but looking at the trackrecord of Microsoft I fear the only objects which will work with this ObjectDataSource are the ones related to ObjectSpaces or at least have to implement an interface related to object spaces.

It's all too closed up. It's not generic. They still don't understand developers want a GENERIC technology for this, after all these years. Not one that is prefabricated and severily limited, but a generic platform which allows you to plug in your own object hierarchies wherever they may come from.

But perhaps what I read in another blog is true, that you can hook a BL class to an ObjectDataSource and with that feed data to a control... However what's the point then :) You can do that in code with 1 line as well...

# re: Is SqlDataSource asking for trouble?

Friday, October 31, 2003 5:08 AM by Thomas Tomiczek    
Frans,

they work with every business object (collection). There are events for craete, select, delete that you can use to handle &quot;your&quot; way of doing it.

It is mainly used for enbling the designers - you se the type of object the ObjectDataSource will contain, then the deisgner can bind and has the metadata.

# re: Is SqlDataSource asking for trouble?

Friday, November 07, 2003 11:42 AM by Anonymous    
Connection strings can be stored securely in the web.config file instead of storing them directly in the SqlDataSource. Most samples show the connection string in the SqlDataSource because it is simpler and requires fewer files. There will be a new syntax for referencing connections in web.config from SqlDataSource.

As far as ObjectDataSource goes, it works with absolutely any object you can throw at it. It also works with ObjectSpaces, since that is an important scenario.

# re: Is SqlDataSource asking for trouble?

Friday, November 07, 2003 10:41 PM by Steve    
Glad to hear it. The &quot;Preview of Web Development with Visual Studio Whidbey&quot; [1] article that is up on MSDN talks about this briefly. I figured it had to be the case but wasn't able to find any confirmation of it in the documentation.

[1] <a target="_new" href="http://msdn.microsoft.com/asp.net/whidbey/default.aspx?pull=/library/en-us/dnaspp/html/WebDevInWhidbey.asp#webdevinwhidbey_topic4">http://msdn.microsoft.com/asp.net/whidbey/default.aspx?pull=/library/en-us/dnaspp/html/WebDevInWhidbey.asp#webdevinwhidbey_topic4</a>

# re: Is SqlDataSource asking for trouble?

Sunday, March 21, 2004 7:52 PM by deebee    
i'm wodering how paging is implemented in this stuff...

# re: Is SqlDataSource asking for trouble?

Sunday, August 15, 2004 10:28 AM by Chuck Bryan    
The SqlDataSource will promote a two tier approach in your solutions. I am sure that most people will still adopt to use designs similar to what they are currently using. Part of the goal of the control is to reduce the amount of ADO.NET code that you write...to be more declarative...or code free, if you will.

The only thing that scares me, are the VB4 flash backs to opening a form and seeing 12 datacontrols on the page. I guarentee that most of us will still continue to write the same amount of ADO.NET code as we do now.

# re: Is SqlDataSource asking for trouble?

Thursday, April 21, 2005 6:45 PM by Flinky Wisty Pomm    
I really don't like the data controls much, but I do have to defend the ObjectDataSource which is happily talking to a DAL we built for a PDA system and displaying the same objects on an ASP.Net page.

The only differences are that I'm using far less code to databind the objects, and that my collection classes have been cut down to

class SomeObjectList : List&lt;SomeObject&gt;{}

As a bonus, I can now give a list of methods to my non-coding boss and let him build display pages with drag-and-drop. It's a full, strongly typed, n-tier architecture, and he doesn't have to know about any of it. It just works.

The new model makes me uneasy, but I can see the benefits.

# re: Is SqlDataSource asking for trouble?

Friday, December 16, 2005 10:25 AM by azzchong    
Dissappointed. The .NET 1.1 has a good feature that allow me to customize my back end design. I try so hard to make my development become more and more easy. But with the latest feature, .NET 2 -- SqlDataSource, it seem pull me back to the beginning (Very Hard). It seem no way to manipulate the Dataset which is store in the memory. (Why dataset able to store in memory but not allow me to get it). My design need so Dataset.

Yes, that is ObjectDataSource, but I still need to code the Business Object Individually. Imagin, if I have 1000 tables and 2000 views. With version 1.1, I no need to code even 1 table or 1 view. .... This is not practise..


# re: Is SqlDataSource asking for trouble?

Friday, December 16, 2005 10:27 AM by azzchong    
Dissappointed. The .NET 1.1 has a good feature that allow me to customize my back end design. I try so hard to make my development become more and more easy. But with the latest feature, .NET 2 -- SqlDataSource, it seem pull me back to the beginning (Very Hard). It seem no way to manipulate the Dataset which is store in the memory. (Why dataset able to store in memory but not allow me to get it). My design need so Dataset.

Yes, that is ObjectDataSource, but I still need to code the Business Object Individually. Imagin, if I have 1000 tables and 2000 views. With version 1.1, I no need to code even 1 table or 1 view. .... This is not practise..


# re: Is SqlDataSource asking for trouble?

Friday, February 03, 2006 4:37 PM by Faisal    
I just wanna hit the jack pot guys...

Post a Comment

 
 
Prove you're not a spammer: 
0 + 1 =