Welcome to WebmasterWorld Guest from 54.166.191.159

Forum Moderators: ocean10000

Message Too Old, No Replies

Question about ASP.NET 2.0 Database Connections

     
5:42 pm on Mar 31, 2007 (gmt 0)

10+ Year Member



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

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...]

 

Featured Threads

Hot Threads This Week

Hot Threads This Month