homepage Welcome to WebmasterWorld Guest from 54.227.20.250
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Question about ASP.NET 2.0 Database Connections
brucec

10+ Year Member



 
Msg#: 3298463 posted 5:42 pm on Mar 31, 2007 (gmt 0)

I find that my first .NET 2.0 web application is very slow. The only thing I can think of is that I have too many database connection objects on the same page.

My first question to anyone is is it possible for multiple server controls to use the same database connection object but with different SQL Commands without calling any subprograms? I do not know how to do this without creating more than one database control.

Also, are these multiple database connections causing the slowness on my site?

Do the database server controls automatically close their connections?

For example:

My .NET 2.0 app has these 4 database server controls:
<asp:AccessDataSource id="ReleaseDate" Runat="Server" DataFile="ff.mdb" SelectCommand="SELECT * FROM schedule where year(release_date)='2005' " />

<asp:AccessDataSource id="sqlSelectAll" Runat="Server" DataFile="ff.mdb" SelectCommand="SELECT distinct director FROM schedule" />

<asp:AccessDataSource id="sqlCategories" Runat="Server" DataFile="ff.mdb" SelectCommand="SELECT distinct category FROM schedule" />

<asp:accessdatasource id="sqlDistinctYear" runat="server" datafile="ff.mdb" selectcommand="SELECT DISTINCT Year([release_date]) AS release_year FROM schedule" />

How can I program multiple controls to use only ONE database connection with different SelectCommand attributes without calling any subprograms?

Thanks,
Bruce

 

aleksl



 
Msg#: 3298463 posted 1:48 pm on Apr 2, 2007 (gmt 0)

is it possible for multiple server controls to use the same database connection object

Always declare connection string in web.config. Example:

<connectionStrings>
<clear />
<add name="LocalAccessDB" connectionString=
"server=.;integrated security=sspi;database=aspnetdb"/>
</connectionStrings>

Put your datasource name into DataSource field, example: <asp:AccessDataSource id="LogalAccessDB" ...>
use the same id everywhere

are these multiple database connections causing the slowness on my site?

yes

Read this:
[msdn2.microsoft.com...]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved