Opening a database connection is a resource intensive and time consuming operation. Connection pooling increases the performance of Web applications by reusing active database connections instead of creating a new connection with every request. Connection pool manager maintains a pool of open database connections. When a new connection requests come in, the pool manager checks if the pool contains any unused connections and returns one if available. If all connections currently in the pool are busy and the maximum pool size has not been reached, the new connection is created and added to the pool. When the pool reaches its maximum size all new connection requests are being queued up until a connection in the pool becomes available or the connection attempt times out.
Connection pooling behavior is controlled by the connection string parameters. The following are four parameters that control most of the connection pooling behavior:
Connect Timeout - controls the wait period in seconds when a new connection is requested, if this timeout expires, an exception will be thrown. Default is 15 seconds.
Max Pool Size - specifies the maximum size of your connection pool. Default is 100. Most Web sites do not use more than 40 connections under the heaviest load but it depends on how long your database operations take to complete.
Min Pool Size - initial number of connections that will be added to the pool upon its creation. Default is zero; however, you may chose to set this to a small number such as 5 if your application needs consistent response times even after it was idle for hours. In this case the first user requests won't have to wait for those database connections to establish.
Pooling - controls if your connection pooling on or off. Default as you may've guessed is true. Read on to see when you may use Pooling=false setting.
For Solve this Problem, set connect timeout period,pooling and max pool size in Sql Connection string in web.config file.
Like
< add key="connstring" value="Server=NILSON1;UID=sa;PWD=;database=final_database;Connect Timeout=90000; pooling='true'; Max Pool Size=70000 " / >
Showing posts with label Dot Net. Show all posts
Showing posts with label Dot Net. Show all posts
April 15, 2009
SQL Connection String
OR
Access Connection String
OR
How to Get Database Connection String
When Your Are confuse in database connection string.
use this simple way.
1.first create one text file.
2.rename with conn. txt
3.now change the extension. Extention name is .udl
4. now your file name is conn.udl
5. Open the conn.udl file
6. u will show data link property
7. select provider name in provider tab(for Sql Server database , select "Microsoft OLE DB Provider for SQL Server")
8. then click on connection tab
9. select database source name,enter user name,password and database name
10. Click on text connection. if you get succeed message.
11. open conn.udl file in text or notepage. You will get connection string
like "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=BusinessCoupon;Data Source=NILSON1"
use this simple way.
1.first create one text file.
2.rename with conn. txt
3.now change the extension. Extention name is .udl
4. now your file name is conn.udl
5. Open the conn.udl file
6. u will show data link property
7. select provider name in provider tab(for Sql Server database , select "Microsoft OLE DB Provider for SQL Server")
8. then click on connection tab
9. select database source name,enter user name,password and database name
10. Click on text connection. if you get succeed message.
11. open conn.udl file in text or notepage. You will get connection string
like "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=BusinessCoupon;Data Source=NILSON1"
March 24, 2009
- IIS installed after visual studio 2005 not working
- IIS installation after visual 2005 install
Hello Friends,
after visual 2005 installation, if u have not installed IIS First and U have install Visual 2005 first. then IIS not working perfect.
U have face this problem?
No worry...try below process.
First run command prompt using
start menu -> Run -> write cmd -> Enter
Then write below link in your command prompt
C:\windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i
Then Enter.
Labels:
Dot Net
January 23, 2009
Server Error in '/' Application - Validation of viewstate MAC failed error
OR
how to solve Mac Failed Error
This error occured when server can't read fast view state value
//use this tag in web config file in < system.web >
< system.web >
< enableeventvalidation="false">
viewstateencryptionmode="Never" >
< / system.web >
Labels:
Dot Net
January 6, 2009
Get return value in asp.net From SQL server
step1 : create stored procedure
CREATE PROCEDURE dyntable (@ptable varchar(50),@new_var int Output )
AS
BEGIN
Select @new_var=count(*) from admin_master
return @new_var
END
GO
step 2: Retrive in asp.net
public void CreatefieldListTable(string strtablename)
{
string intconfirm = "";
SqlConnection conn = new SqlConnection(objconn.GetConnection());
SqlCommand cmdInsert = new SqlCommand("dyntable", conn);
cmdInsert.CommandType = CommandType.StoredProcedure;
cmdInsert.Parameters.AddWithValue("@ptable", strtablename);
SqlParameter var =new SqlParameter("@new_var",SqlDbType.Int);
var.Direction = ParameterDirection.Output;
cmdInsert.Parameters.Add(var);
conn.Open();
SqlDataReader dtread;
cmdInsert.ExecuteNonQuery();
string str = Convert.ToString(cmdInsert.Parameters["@new_var"].Value);
conn.Close();
}
December 30, 2008
How to use different Server Variables
: the page the visitor came from.
Request.ServerVariables("HTTP_REFERER")
: get a visitors IP address
: get a visitors IP address
Request.ServerVariables("REMOTE_ADDR")
:Find host name of client
:Find host name of client
Request.ServerVariables("REMOTE_HOST")
: Find server domain name
Request.ServerVariables("SERVER_NAME")
: returns the software running on the server
Request.ServerVariables("SERVER_SOFTWARE")%
:Display the virtual path to the script or application being executed
Request.ServerVariables("SCRIPT_NAME")
:Display users browser and opertaing system
Request.ServerVariables("HTTP_USER_AGENT")
Labels:
Dot Net
how to send a mail message from a Web Forms page
step 1: Import System.Web.Mail Namespace in Html Code
step 2 : add below code in script tag using script language C#
void Page_Load()
{
if (!IsPostBack)
{
txtTo.Text="john@contoso.com";
txtFrom.Text="marsha@contoso.com";
txtCc.Text="fred@contoso.com";
txtBcc.Text="wilma@contoso.com";
txtSubject.Text="Hello";
txtBody.Text="This is a test message.";
txtAttach.Text=@"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Sunset.jpg,"
+ @"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Winter.jpg";
txtBodyEncoding.Text = Encoding.ASCII.EncodingName;
txtBodyFormat.Text="HTML";
txtPriority.Text="Normal";
txtUrlContentBase.Text="http://www.contoso.com/images";
txtUrlContentLocation.Text="http://www.contoso.com/images";
// Name of relay mail server in your domain.
txtMailServer.Text="smarthost";
}
}
void btnSubmit_Click(Object sender, EventArgs e)
{
string sTo, sFrom, sSubject, sBody;
string sAttach, sCc, sBcc, sBodyEncoding;
string sBodyFormat, sMailServer, sPriority;
string sUrlContentBase, sUrlContentLocation;
int iLoop1;
sTo = txtTo.Text.Trim();
sFrom = txtFrom.Text.Trim();
sSubject = txtSubject.Text.Trim();
sBody = txtBody.Text.Trim();
sAttach = txtAttach.Text.Trim();
sCc = txtCc.Text.Trim();
sBcc = txtBcc.Text.Trim();
sBodyFormat = txtBodyFormat.Text.Trim();
sBodyEncoding = txtBodyEncoding.Text.Trim();
sPriority = txtPriority.Text.Trim();
sUrlContentBase = txtUrlContentBase.Text.Trim();
sUrlContentLocation = txtUrlContentLocation.Text.Trim();
sMailServer = txtMailServer.Text.Trim();
MailMessage MyMail = new MailMessage();
MyMail.From = sFrom;
MyMail.To = sTo;
MyMail.Subject = sSubject;
MyMail.Body = sBody;
MyMail.Cc = sCc;
MyMail.Bcc = sBcc;
MyMail.UrlContentBase = sUrlContentBase;
MyMail.UrlContentLocation = sUrlContentLocation;
if (txtBodyEncoding.Text == Encoding.UTF7.EncodingName)
MyMail.BodyEncoding = Encoding.UTF7;
else if (txtBodyEncoding.Text == Encoding.UTF8.EncodingName)
MyMail.BodyEncoding = Encoding.UTF8;
else
MyMail.BodyEncoding = Encoding.ASCII;
switch (sBodyFormat.ToUpper())
{
case "HTML":
MyMail.BodyFormat = MailFormat.Html;
break;
default:
MyMail.BodyFormat = MailFormat.Text;
break;
}
switch (sPriority.ToUpper())
{
case "HIGH":
MyMail.Priority = MailPriority.High;
break;
case "LOW":
MyMail.Priority = MailPriority.Low;
break;
default:
MyMail.Priority = MailPriority.Normal;
break;
}
// Build an IList of mail attachments.
if (sAttach != "")
{
char[] delim = new char[] {','};
foreach (string sSubstr in sAttach.Split(delim))
{
MailAttachment MyAttachment = new MailAttachment(sSubstr);
MyMail.Attachments.Add(MyAttachment);
}
}
SmtpMail.SmtpServer = sMailServer;
SmtpMail.Send(MyMail);
lblMsg1.Text="C# Message sent to " + MyMail.To;
}
void btnClear_Click(Object sender, EventArgs e)
{
lblMsg1.Text="";
txtTo.Text="";
txtFrom.Text="";
txtSubject.Text="";
txtBody.Text="";
txtAttach.Text="";
txtBcc.Text="";
txtCc.Text="";
txtBodyEncoding.Text="";
txtBodyFormat.Text="";
txtPriority.Text="";
txtUrlContentBase.Text="";
txtUrlContentLocation.Text="";
txtMailServer.Text="";
btnSubmit.Text="Submit";
}
step 2 : add below code in script tag using script language C#
void Page_Load()
{
if (!IsPostBack)
{
txtTo.Text="john@contoso.com";
txtFrom.Text="marsha@contoso.com";
txtCc.Text="fred@contoso.com";
txtBcc.Text="wilma@contoso.com";
txtSubject.Text="Hello";
txtBody.Text="This is a test message.";
txtAttach.Text=@"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Sunset.jpg,"
+ @"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Winter.jpg";
txtBodyEncoding.Text = Encoding.ASCII.EncodingName;
txtBodyFormat.Text="HTML";
txtPriority.Text="Normal";
txtUrlContentBase.Text="http://www.contoso.com/images";
txtUrlContentLocation.Text="http://www.contoso.com/images";
// Name of relay mail server in your domain.
txtMailServer.Text="smarthost";
}
}
void btnSubmit_Click(Object sender, EventArgs e)
{
string sTo, sFrom, sSubject, sBody;
string sAttach, sCc, sBcc, sBodyEncoding;
string sBodyFormat, sMailServer, sPriority;
string sUrlContentBase, sUrlContentLocation;
int iLoop1;
sTo = txtTo.Text.Trim();
sFrom = txtFrom.Text.Trim();
sSubject = txtSubject.Text.Trim();
sBody = txtBody.Text.Trim();
sAttach = txtAttach.Text.Trim();
sCc = txtCc.Text.Trim();
sBcc = txtBcc.Text.Trim();
sBodyFormat = txtBodyFormat.Text.Trim();
sBodyEncoding = txtBodyEncoding.Text.Trim();
sPriority = txtPriority.Text.Trim();
sUrlContentBase = txtUrlContentBase.Text.Trim();
sUrlContentLocation = txtUrlContentLocation.Text.Trim();
sMailServer = txtMailServer.Text.Trim();
MailMessage MyMail = new MailMessage();
MyMail.From = sFrom;
MyMail.To = sTo;
MyMail.Subject = sSubject;
MyMail.Body = sBody;
MyMail.Cc = sCc;
MyMail.Bcc = sBcc;
MyMail.UrlContentBase = sUrlContentBase;
MyMail.UrlContentLocation = sUrlContentLocation;
if (txtBodyEncoding.Text == Encoding.UTF7.EncodingName)
MyMail.BodyEncoding = Encoding.UTF7;
else if (txtBodyEncoding.Text == Encoding.UTF8.EncodingName)
MyMail.BodyEncoding = Encoding.UTF8;
else
MyMail.BodyEncoding = Encoding.ASCII;
switch (sBodyFormat.ToUpper())
{
case "HTML":
MyMail.BodyFormat = MailFormat.Html;
break;
default:
MyMail.BodyFormat = MailFormat.Text;
break;
}
switch (sPriority.ToUpper())
{
case "HIGH":
MyMail.Priority = MailPriority.High;
break;
case "LOW":
MyMail.Priority = MailPriority.Low;
break;
default:
MyMail.Priority = MailPriority.Normal;
break;
}
// Build an IList of mail attachments.
if (sAttach != "")
{
char[] delim = new char[] {','};
foreach (string sSubstr in sAttach.Split(delim))
{
MailAttachment MyAttachment = new MailAttachment(sSubstr);
MyMail.Attachments.Add(MyAttachment);
}
}
SmtpMail.SmtpServer = sMailServer;
SmtpMail.Send(MyMail);
lblMsg1.Text="C# Message sent to " + MyMail.To;
}
void btnClear_Click(Object sender, EventArgs e)
{
lblMsg1.Text="";
txtTo.Text="";
txtFrom.Text="";
txtSubject.Text="";
txtBody.Text="";
txtAttach.Text="";
txtBcc.Text="";
txtCc.Text="";
txtBodyEncoding.Text="";
txtBodyFormat.Text="";
txtPriority.Text="";
txtUrlContentBase.Text="";
txtUrlContentLocation.Text="";
txtMailServer.Text="";
btnSubmit.Text="Submit";
}
Labels:
Dot Net
December 23, 2008
How to get return value from SQl query thru Dot Net
first create the "dyntable " procedure
CREATE PROCEDURE dyntable (@new_var int Output )
AS
BEGIN
Select @new_var=count(*) from admin_master
return @new_var
END
GO
Get return value in Asp.Net
string intconfirm = "";
SqlConnection conn = new SqlConnection(objconn.GetConnection());
SqlCommand cmdInsert = new SqlCommand("dyntable", conn);
cmdInsert.CommandType = CommandType.StoredProcedure;
SqlParameter var =new SqlParameter("@new_var",SqlDbType.Int);
var.Direction = ParameterDirection.Output;
cmdInsert.Parameters.Add(var);
conn.Open();
SqlDataReader dtread;
cmdInsert.ExecuteNonQuery();
string str = Convert.ToString(cmdInsert.Parameters["@new_var"].Value);
conn.Close();
Labels:
Dot Net
Subscribe to:
Posts (Atom)