|
When Connection Pooling is enabled, connections aren't opened and closed as such, rather a whole bunch are opened all at once and then left open. When you get a connection from the pool you are retrieving a already open connection, and when you close the connection you are simply returning that connection back to the pool but in a left open state. Or so I believe.
Thats means in theory there would be no difference between the two implementations you've shown, however you could always test the performance by measuring the execution speed of the page for the two implementations, and see if there's any difference.
However, good practices dictate that you should only hold onto connection objects for as short a time as possible, as even with connection pooling, retrieving the connection from the pool means that other processes or clients can't use it. So the first practice would probably be the best approach, but if your entire site is done using the second practice, I wouldn't loose sleep over it
Connection pooling is automatic provided you meet the following conditions, the connection string must remain exactly the same (even adding spaces to the string will effect connection pooling, so make sure you have the string stored inside the web.config file, or in some external source, and not hard coded into the class. Also only certain vendors support it I believe, you're using Sql Server with SqlConnection class?
EDIT: Sorry misread your post you implemented the first practice which is good (opening and closing connections as needed for each Stored Procedure). If you're calling all four Stored Procedures immediately one after the other, then you could probably use the second practive of holding onto one connection object.
-- modified at 11:23 Sunday 26th November, 2006
|
|
|
|
|
You said
so make sure you have the string stored inside the web.config file, or in some external source, and not hard coded into the class.
Thank you very much for your help. What is wrong with hard coding the connection string in the class ??? I have defined it in my base business class. Why it affects connection pooling ??
|
|
|
|
|
Easier deployment, if you have to change the connection string for when the web application gets deployed, it's easier to edit an xml file as oppose to edit a class file then recompile it etc.
As for Connection Pooling, as long as you have the connection string defined in one place its fine. If you have the same connection string defined in multiple classes in one class you might write...
"Data Source=localhost;Initial Catalog=databaseName;....."
Whereas in another class you write...
"Data Source=localhost; Initial Catalog=databaseName;....."
Notice the space between localhost; and Initial. Because the strings are different it will clause connection pool to be reset, or use a different pool. Defining the string in one place (such as your business base class) avoids these potential typos.
|
|
|
|
|
Thank you for help. I saw your site ,how do u find execution time of your page ?? sounds intresting . Explain to me please if your like .
|
|
|
|
|
In your code behind file (or wherever you put code)....
private int startTime;<br />
<br />
protected void Page_Init(object sender, EventArgs e)<br />
{<br />
startTime = Environment.TickCount;<br />
}<br />
<br />
protected void Page_PreRender(object sender, EventArgs e)<br />
{<br />
int endTime = Environment.TickCount;<br />
<br />
double executionTimeInSeconds = (double)(endTime - startTime) / 1000.0;<br />
<br />
SomeLabelInYourPageSomewhere.Text = executionTimeInSeconds.ToString();<br />
}
Basically you start the timer early in the page event cycle (the Page_Init) and stop the timer late in the cycle (Page_PreRender) which captures the page execution time for almost everything in between (Page_Onload, Control Initialisation, Data bindind, Events from client side button presses etc.).
|
|
|
|
|
|
Hi All,
I don't know in which message board I've to rise this question.. Please help me..
I've Developed a Asp.net shopping cart web application with vb.net as code behind.. SQL server as Back end..
I am in need of delete the records of the particular table at every day midnight and i want to have the blank table in next morning..
Is it possible to do?? Please help me in this issue
Thanks in Advance
|
|
|
|
|
maybe u should look for triggers based on time
Best Regards
3ala2
|
|
|
|
|
The best option is to define a JOB in sql servere and schedual it accordingly.You will find plenty of articles through google to do so.
|
|
|
|
|
Hi and thanks for attending at my message.
In the project I'm currently working, users need to capture a lot of information in a site, so I thought I could build a Web Service to do this. I was thinking in make that the web service pass the controls that are need, because the information they're gonna be capturing it can be very diferent between one form and another, so I want to avoid codding a lot of diferents webforms.
I thought that I could build a Web Service that can command a page to show o not some of the controls on the site, so the user just got to select the form and presto! they got the all the controls they need to capture the information.
But then I remembered: I can only pass data through the web service. The curiosity is really big...does anyone knows a way to pass controls through web services? can anyone tell me of another way to show diferents kind of controls for capturing data besides show/hide panel? or even another approach to solve this kind of thing?
Any suggestions or advices will be great!!!
Thanks every body!!!
A Programmer is as many times Programmer as Lenguages knows
|
|
|
|
|
Hi,
If you are planning to have dynamic controls ,You will have some Algo in your mind to store this data as well.
If you'r clear with that then you will have to create the controls dynamically on the basis of controls collection returns from your webservice .Then once user inputs data and submits form you will have to read these controls back.
donno wether i am able to make myself clear.....
Regards
|
|
|
|
|
I was thinking in something just like you were saying, send a collection of controls and then get them back and iterate through them, but I don't think it's a good idea anymore, because of the codding I'll have to do for all the arrangement of controls.
Now I'm thinking to do something diferent, I like the idea of a web service that only recive a customized object, even when I still have some problems passing those thing of object to a web service. I've done some googling and I decide to work with multiview/view controls, it seams pretty easy.
So, now I'm asking for direction on doing that: pass a cutomize object to a web service.
If you payback knows something about that it'll be great!!
Thanks again.
The limits of my language are the limits of my mind
|
|
|
|
|
I want to send an email using asp.net .. the main problem is that i dont know which smtp i must use? i want to run this on the server. I am using the smtp.mail.yahoo.com but its not working.
The Code:
Dim objEmail As New MailMessage<br />
objEmail.To = "buyproductsmalta@yahoo.com"<br />
objEmail.From = txtEmail.Text<br />
objEmail.Subject = "Query: " & "From " & txtName.Text & " " & txtSurname.Text<br />
objEmail.Body = txtQuestions.Text<br />
objEmail.Priority = MailPriority.High<br />
SmtpMail.SmtpServer = "localhost"<br />
<br />
Try<br />
SmtpMail.Send(objEmail)<br />
lblSent.Visible = True<br />
lblSent.Text = "The query has been sent...."<br />
Catch exc As Exception<br />
lblSent.Visible = True<br />
lblSent.Text = "Not Sent .. Please try Again"<br />
End Try
Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.
|
|
|
|
|
Does you mail server (smtp.mail.yahoo.com) require authentication, eg. username and password? If so you'll need to set that, also could you provide the error message that the exception is throwing...
Catch exc As Exception
lblSent.Visible = True
lblSent.Text = "Exception was: " & exec.Message
End Try
|
|
|
|
|
The error is this: Could not access 'CDO.Message' object.
SmtpMail.SmtpServer = "smtp.mail.yahoo.com"<br />
<br />
Try<br />
SmtpMail.Send(objEmail)<br />
lblSent.Visible = True<br />
lblSent.Text = "The query has been sent...."<br />
Catch exc As Exception<br />
lblSent.Visible = True<br />
'lblSent.Text = "Not Sent .. Please try Again"<br />
lblSent.Text = exc.Message<br />
End Try
Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.
|
|
|
|
|
After some years without mayor problems, my Visual Studio 2003 began to crash every now and then when working on a ASP.NET-project. At the moment the intervals are keeping getting shorter (strange !).
By now after every couple of lines of code I do a save not knowing when the next crash is coming up. Sometimes switching from code to design-view is enough...
I get a error and VS 2003 quits and sometimes it just even vanishes without no message what so ever.
This situation isn't workable anymore.
I've done some reinstalls, but the problem stays.
Then I realised I installed IE7 Beta some months ago ! Could this be the problem ?
To uninstall IE7 could maybe solve the problem, but IE7 has major improvements over IE6, so I would like to keep it (as M$ will force us in a short while anyway
Could IE7 really be the source for my crashes and has someone of you out there had similar problems AND maybe workarounds?
Thx in advance.
-- modified at 18:50 Saturday 25th November, 2006
|
|
|
|
|
Perhaps... a beta is still a beta. You should install the final version of IE7 instead.
---
b { font-weight: normal; }
|
|
|
|
|
Pat Krimson wrote: I installed IE7 Beta some months ago !
Why are you still using IE7 Beta?
I have a colleague who's using IE7 with ASP.NET 2003 and he's not had problems of this sort. Mind you he was formerly using the Beta and had no problems either. I suspect your problem is caused by something else.
Pat Krimson wrote: as M$ will force us in a short while anyway
At a guess I would say it won't be long before any new MS products that interact with the web (which is virtually everything) will mandate IE7 as a prerequisite. Does Office 2007? If not, VS 2007 is bound to require IE7.
Kevin
|
|
|
|
|
I realise I still have Beta 3 on my system... Thought by now I would have the final version. Downloading it now, hope this helps.
Thx to U all...
|
|
|
|
|
hi there,
i want ur help guys on how can i read froma word 2003 document and save content to sql database table. Offcourse the word file is rearranged to hold data in a specific order to be abe to use the data correctly "I guess!"
thanks
|
|
|
|
|
Well I'm no expert in that, but it sounds like you just have to figure out how word o3 works...I mean Document Object Model must have some sort of an API to be able to read...just like we read from a text file in notepad.
If you don't go after what you want, you'll never have it.
If you don't ask, the answer is always no. If you don't step
forward, you're always in the same place. -Nora Roberts
|
|
|
|
|
I have a .ashx file that I would like to incorporate into my project, but I am having some issues with Visual Studio 2003. The file extension is not recognized by the IDE, so I cannot set it as the start page or view highlighted syntax.
Is there a way to get Visual Stuido 2003 to recognize .ashx files as valid C# source files?
Thank you.
|
|
|
|
|
ashx is a handler, it can't be set as the start page.
only two letters away from being an asset
|
|
|
|
|
Ok, thanks for the info, but how can I get DevStudio to recognize it so the syntax highlighting works?
|
|
|
|
|
hi all,
i want i m new to web world (ASP.NET), to search from site sites using goolge, i mean i m providing searching through goole.i had text field when user write text on text field and hit the search google button then that text will be search from the google and shown on seperate page.
Regards.
Tasleem Arif
|
|
|
|