Solved

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

Posted on 2009-06-29
1
297 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

622 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