Solved

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

Posted on 2009-06-29
1
295 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 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