Solved

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

Posted on 2009-06-29
1
285 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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
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 video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now