Solved

using sqldatasource vs connecting to database in code, asp.net

Posted on 2009-06-29
1
293 Views
Last Modified: 2012-05-07
Is there much difference using a sqldatasource on the .aspx page vs connecting via code?
like
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>"
        SelectCommand="sp_INSERT_to_HistoryTable" SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:ControlParameter ControlID="Comment1A_Set1_10" Name="Acct"
                PropertyName="Text" Type="String" />
            <asp:ControlParameter ControlID="Comment1A_Set2_10" Name="SerNum"
                PropertyName="Text" Type="String" />
            <asp:Parameter Name="Str1" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
vs in code, something like this:
        Dim SeaConn As New System.Data.OleDb.OleDbConnection("Provider=SQLOLEDB.1;xxxxxxxxxxx")
        Dim cmd As New OleDbCommand(strSQL)
        SeaConn .Open()
        cmd.Connection = SeaConn
        cmd.ExecuteNonQuery()
        SeaConn .Close()
0
Comment
Question by:avoorheis
1 Comment
 
LVL 7

Accepted Solution

by:
Chris-Chambers earned 500 total points
ID: 24737335
Hi,

I've only tried using an sqldatasource once, and I found that the connection took between 10 an 15 times longer to connect (or rather the page took that much longer to render) than using code.

(This was tried on a production server in live conditions.)

Of course there could have been other factors at work but I have never bothered trying again, the code version works well enough for me with no performance worries to keep me up at night.

Hope this helps,

Chris.

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question