467,136 Members | 1,378 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,136 developers. It's quick & easy.

Databind Error???

I'm having an issue and wanted to pass it by everyone to see what you think.
Here is my code.
//Code Start
searchs = new
Maritz.Learning.HP.Callcenter.BusinessServices.Sea rchs(base.ConnectionString);
searchs.Search(this.FirstNameTextbox.Text, this.LastNameTextbox.Text,

this.EmailTextbox.Text, this.CityTextBox.Text, this.StateTextBox.Text,
this.ZipTextBox.Text, this.IssueTextBox.Text, this.CompanyNameTextBox.Text,
Convert.ToInt32(this.SiteDropDownList.SelectedValu e.ToString()),
Convert.ToInt32(this.StatusDropDownList.SelectedVa lue.ToString()));
this.ResultsDataGrid.DataSource = searchs;

this.ResultsDataGrid.DataBind();
//Code End

This is on a click event from a web page. When the button is clicked the
searchs object is created and populated from a sproc. Then simply set the
datasource and bind it. This works perfectly, however, if I click the
button a 2nd, 3rd, or 4th time (usually on the 4th click) everything works
until I get to the DataBind(). The system will hang on that line and
produce this error.

Server Error in '/' Application.

--------------------------------------------------------------------------------

Failed to open a data connection
Server=FENSQLLIBD01;database=HPCustomerSupport;use r
id=HPCustomerSupport;password=*2rT44Y* - please check the connection string
and security settings!
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Exception: Failed to open a data connection
Server=FENSQLLIBD01;database=HPCustomerSupport;use r
id=HPCustomerSupport;password=*2rT44Y* - please check the connection string
and security settings!

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[Exception: Failed to open a data connection
Server=FENSQLLIBD01;database=HPCustomerSupport;use r
id=HPCustomerSupport;password=*2rT44Y* - please check the connection string
and security settings!]
Maritz.Learning.HP.Web.CallCenter.Tracking.searcht ask.SearchButton_Click(Object
sender, EventArgs e) in c:\inetpub\wwwroot\hplogging\search.aspx.cs:90
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl,
String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277


--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573

Has anyone ever seen anything like this?

Doug


Aug 3 '06 #1
  • viewed: 2162
Share:
3 Replies
Doug,
You haven't included any of the code from your searchs object so nobody can
really tell what you are doing code-wise there. However, if it works the
first time and you get a connection failure in subsequent attempts you can be
pretty sure it's because the original (first) connection wasn't closed /
disposed properly.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Doug Durrett" wrote:
I'm having an issue and wanted to pass it by everyone to see what you think.
Here is my code.
//Code Start
searchs = new
Maritz.Learning.HP.Callcenter.BusinessServices.Sea rchs(base.ConnectionString);
searchs.Search(this.FirstNameTextbox.Text, this.LastNameTextbox.Text,

this.EmailTextbox.Text, this.CityTextBox.Text, this.StateTextBox.Text,
this.ZipTextBox.Text, this.IssueTextBox.Text, this.CompanyNameTextBox.Text,
Convert.ToInt32(this.SiteDropDownList.SelectedValu e.ToString()),
Convert.ToInt32(this.StatusDropDownList.SelectedVa lue.ToString()));
this.ResultsDataGrid.DataSource = searchs;

this.ResultsDataGrid.DataBind();
//Code End

This is on a click event from a web page. When the button is clicked the
searchs object is created and populated from a sproc. Then simply set the
datasource and bind it. This works perfectly, however, if I click the
button a 2nd, 3rd, or 4th time (usually on the 4th click) everything works
until I get to the DataBind(). The system will hang on that line and
produce this error.

Server Error in '/' Application.

--------------------------------------------------------------------------------

Failed to open a data connection
Server=FENSQLLIBD01;database=HPCustomerSupport;use r
id=HPCustomerSupport;password=*2rT44Y* - please check the connection string
and security settings!
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Exception: Failed to open a data connection
Server=FENSQLLIBD01;database=HPCustomerSupport;use r
id=HPCustomerSupport;password=*2rT44Y* - please check the connection string
and security settings!

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[Exception: Failed to open a data connection
Server=FENSQLLIBD01;database=HPCustomerSupport;use r
id=HPCustomerSupport;password=*2rT44Y* - please check the connection string
and security settings!]
Maritz.Learning.HP.Web.CallCenter.Tracking.searcht ask.SearchButton_Click(Object
sender, EventArgs e) in c:\inetpub\wwwroot\hplogging\search.aspx.cs:90
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl,
String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277


--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573

Has anyone ever seen anything like this?

Doug


Aug 3 '06 #2
Peter,

Here is the process we are using. Someone brainless where I work wrote a
wrapper object looking just like the Microsoft command object and even named
it the same/simular. I'm not opening a connection, I'm setting the
connection string to the command object and even disposing it and setting it
to null in the finally statment. Well here it is... hope it's not too long.

public virtual void Search(string p_firstName, string p_lastName, string
p_email,
string p_city, string p_state, string p_zip, string p_issue, string
p_companyName, int p_siteId,
int p_statusId)
{
SqlClient command = null;

try
{
command = new SqlClient(connectionString);
command.SetInputParameter("@p_FirstName", SqlDbType.VarChar,
p_firstName);
command.SetInputParameter("@p_LastName", SqlDbType.VarChar, p_lastName);
command.SetInputParameter("@p_Email", SqlDbType.VarChar, p_email);
command.SetInputParameter("@p_City", SqlDbType.VarChar, p_city);
command.SetInputParameter("@p_State", SqlDbType.VarChar, p_state);
command.SetInputParameter("@p_Zip", SqlDbType.VarChar, p_zip);
command.SetInputParameter("@p_Issue", SqlDbType.VarChar, p_issue);
command.SetInputParameter("@p_CompanyName", SqlDbType.VarChar,
p_companyName);
//command.SetInputParameter("@p_TaskDateTime", SqlDbType.DateTime,
p_taskDateTime);
//command.SetInputParameter("@p_TaskActivityComment" , SqlDbType.VarChar,
p_taskActivityComment);
//command.SetInputParameter("@p_TaskActivityLastModD ate",
SqlDbType.DateTime, p_taskActivityLastModDate);
command.SetInputParameter("@p_SiteId", SqlDbType.Int, p_siteId);
command.SetInputParameter("@p_StatusId", SqlDbType.Int, p_statusId);
Load(command, "Search");
}
catch(Exception ex)
{
throw ex;
}
finally
{
command.Dispose();
command = null;
}
}

protected virtual void Load(SqlClient command, string commandText)
{
IDataReader reader = null;
Search search = null;

try
{
//Execute command object
command.ExecuteSqlCommand(commandText, out reader);
//Iterate through reader object to read and set the values
while(reader.Read())
{
search = new Search(base.connectionString);
//Set the reader field values to channel object

search.SetValues(reader);
//Add to chanels collection

this.Add(search);
search = null;
}
}
catch(Exception ex)
{
throw ex;
}
finally
{
reader.Close();
reader.Dispose();
reader = null;
search = null;
command.Dispose();
command = null;

}
}

private void executeSqlCommand(string CommandText, out
IDataReader DataReader)
{

this.Command = new sqlClient.SqlCommand(CommandText);
this.Command.CommandTimeout = 15;
this.ExecuteSqlCommand(this.Command, CommandType.StoredProcedure, out
DataReader);
}
public virtual void SetValues(IDataReader reader)
{
try
{
if (reader["ContactId"] != DBNull.Value)
contactId = Convert.ToInt32(reader["ContactId"]);

if (reader["TaskId"] != DBNull.Value)
taskId = Convert.ToInt32(reader["TaskId"]);

if (reader["LastName"] != DBNull.Value)
lastName = reader["LastName"].ToString();

if (reader["FirstName"] != DBNull.Value)
firstName = reader["FirstName"].ToString();

if (reader["City"] != DBNull.Value)
city = reader["City"].ToString();

if (reader["State"] != DBNull.Value)
state = reader["State"].ToString();

if (reader["Zip"] != DBNull.Value)
zip = reader["Zip"].ToString();

if (reader["Email"] != DBNull.Value)
email = reader["Email"].ToString();

if (reader["Issue"] != DBNull.Value)
issue = reader["Issue"].ToString();

if (reader["CompanyName"] != DBNull.Value)
companyname = reader["CompanyName"].ToString();

// if (reader["TaskActivityComment"] != DBNull.Value)
// taskActivityComment = reader["TaskActivityComment"].ToString();

if (reader["SiteId"] != DBNull.Value)
siteId = Convert.ToInt32(reader["SiteId"]);

if (reader["StatusId"] != DBNull.Value)
statusId = Convert.ToInt32(reader["StatusId"]);

// if (reader["ActivityName"] != DBNull.Value)
// activityname = reader["activityname"].ToString();
}

catch(Exception ex)
{
throw ex;
}
}



"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:B1**********************************@microsof t.com...
Doug,
You haven't included any of the code from your searchs object so nobody
can
really tell what you are doing code-wise there. However, if it works the
first time and you get a connection failure in subsequent attempts you can
be
pretty sure it's because the original (first) connection wasn't closed /
disposed properly.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Doug Durrett" wrote:
>I'm having an issue and wanted to pass it by everyone to see what you
think.
Here is my code.
//Code Start
searchs = new
Maritz.Learning.HP.Callcenter.BusinessServices.Se archs(base.ConnectionString);
searchs.Search(this.FirstNameTextbox.Text, this.LastNameTextbox.Text,

this.EmailTextbox.Text, this.CityTextBox.Text, this.StateTextBox.Text,
this.ZipTextBox.Text, this.IssueTextBox.Text,
this.CompanyNameTextBox.Text,
Convert.ToInt32(this.SiteDropDownList.SelectedVal ue.ToString()),
Convert.ToInt32(this.StatusDropDownList.SelectedV alue.ToString()));
this.ResultsDataGrid.DataSource = searchs;

this.ResultsDataGrid.DataBind();
//Code End

This is on a click event from a web page. When the button is clicked
the
searchs object is created and populated from a sproc. Then simply set
the
datasource and bind it. This works perfectly, however, if I click the
button a 2nd, 3rd, or 4th time (usually on the 4th click) everything
works
until I get to the DataBind(). The system will hang on that line and
produce this error.

Server Error in '/' Application.

--------------------------------------------------------------------------------

Failed to open a data connection
Server=FENSQLLIBD01;database=HPCustomerSupport;us er
id=HPCustomerSupport;password=*2rT44Y* - please check the connection
string
and security settings!
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Exception: Failed to open a data connection
Server=FENSQLLIBD01;database=HPCustomerSupport;us er
id=HPCustomerSupport;password=*2rT44Y* - please check the connection
string
and security settings!

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[Exception: Failed to open a data connection
Server=FENSQLLIBD01;database=HPCustomerSupport;us er
id=HPCustomerSupport;password=*2rT44Y* - please check the connection
string
and security settings!]
Maritz.Learning.HP.Web.CallCenter.Tracking.search task.SearchButton_Click(Object
sender, EventArgs e) in c:\inetpub\wwwroot\hplogging\search.aspx.cs:90
System.Web.UI.WebControls.Button.OnClick(EventArg s e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IP ostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEv entHandler
sourceControl,
String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCo llection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277


--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.4322.573;
ASP.NET
Version:1.1.4322.573

Has anyone ever seen anything like this?

Doug



Aug 3 '06 #3
Doug,
Agreed. It's a first-class mess. I don't see anywhere in there that a
connection is actually being closed. If a SqlDataReader, and the
CommandBehavior.CloseConnection enum was being used, that would be a good
start.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Doug Durrett" wrote:
Peter,

Here is the process we are using. Someone brainless where I work wrote a
wrapper object looking just like the Microsoft command object and even named
it the same/simular. I'm not opening a connection, I'm setting the
connection string to the command object and even disposing it and setting it
to null in the finally statment. Well here it is... hope it's not too long.

public virtual void Search(string p_firstName, string p_lastName, string
p_email,
string p_city, string p_state, string p_zip, string p_issue, string
p_companyName, int p_siteId,
int p_statusId)
{
SqlClient command = null;

try
{
command = new SqlClient(connectionString);
command.SetInputParameter("@p_FirstName", SqlDbType.VarChar,
p_firstName);
command.SetInputParameter("@p_LastName", SqlDbType.VarChar, p_lastName);
command.SetInputParameter("@p_Email", SqlDbType.VarChar, p_email);
command.SetInputParameter("@p_City", SqlDbType.VarChar, p_city);
command.SetInputParameter("@p_State", SqlDbType.VarChar, p_state);
command.SetInputParameter("@p_Zip", SqlDbType.VarChar, p_zip);
command.SetInputParameter("@p_Issue", SqlDbType.VarChar, p_issue);
command.SetInputParameter("@p_CompanyName", SqlDbType.VarChar,
p_companyName);
//command.SetInputParameter("@p_TaskDateTime", SqlDbType.DateTime,
p_taskDateTime);
//command.SetInputParameter("@p_TaskActivityComment" , SqlDbType.VarChar,
p_taskActivityComment);
//command.SetInputParameter("@p_TaskActivityLastModD ate",
SqlDbType.DateTime, p_taskActivityLastModDate);
command.SetInputParameter("@p_SiteId", SqlDbType.Int, p_siteId);
command.SetInputParameter("@p_StatusId", SqlDbType.Int, p_statusId);
Load(command, "Search");
}
catch(Exception ex)
{
throw ex;
}
finally
{
command.Dispose();
command = null;
}
}

protected virtual void Load(SqlClient command, string commandText)
{
IDataReader reader = null;
Search search = null;

try
{
//Execute command object
command.ExecuteSqlCommand(commandText, out reader);
//Iterate through reader object to read and set the values
while(reader.Read())
{
search = new Search(base.connectionString);
//Set the reader field values to channel object

search.SetValues(reader);
//Add to chanels collection

this.Add(search);
search = null;
}
}
catch(Exception ex)
{
throw ex;
}
finally
{
reader.Close();
reader.Dispose();
reader = null;
search = null;
command.Dispose();
command = null;

}
}

private void executeSqlCommand(string CommandText, out
IDataReader DataReader)
{

this.Command = new sqlClient.SqlCommand(CommandText);
this.Command.CommandTimeout = 15;
this.ExecuteSqlCommand(this.Command, CommandType.StoredProcedure, out
DataReader);
}
public virtual void SetValues(IDataReader reader)
{
try
{
if (reader["ContactId"] != DBNull.Value)
contactId = Convert.ToInt32(reader["ContactId"]);

if (reader["TaskId"] != DBNull.Value)
taskId = Convert.ToInt32(reader["TaskId"]);

if (reader["LastName"] != DBNull.Value)
lastName = reader["LastName"].ToString();

if (reader["FirstName"] != DBNull.Value)
firstName = reader["FirstName"].ToString();

if (reader["City"] != DBNull.Value)
city = reader["City"].ToString();

if (reader["State"] != DBNull.Value)
state = reader["State"].ToString();

if (reader["Zip"] != DBNull.Value)
zip = reader["Zip"].ToString();

if (reader["Email"] != DBNull.Value)
email = reader["Email"].ToString();

if (reader["Issue"] != DBNull.Value)
issue = reader["Issue"].ToString();

if (reader["CompanyName"] != DBNull.Value)
companyname = reader["CompanyName"].ToString();

// if (reader["TaskActivityComment"] != DBNull.Value)
// taskActivityComment = reader["TaskActivityComment"].ToString();

if (reader["SiteId"] != DBNull.Value)
siteId = Convert.ToInt32(reader["SiteId"]);

if (reader["StatusId"] != DBNull.Value)
statusId = Convert.ToInt32(reader["StatusId"]);

// if (reader["ActivityName"] != DBNull.Value)
// activityname = reader["activityname"].ToString();
}

catch(Exception ex)
{
throw ex;
}
}



"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:B1**********************************@microsof t.com...
Doug,
You haven't included any of the code from your searchs object so nobody
can
really tell what you are doing code-wise there. However, if it works the
first time and you get a connection failure in subsequent attempts you can
be
pretty sure it's because the original (first) connection wasn't closed /
disposed properly.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Doug Durrett" wrote:
I'm having an issue and wanted to pass it by everyone to see what you
think.
Here is my code.
//Code Start
searchs = new
Maritz.Learning.HP.Callcenter.BusinessServices.Sea rchs(base.ConnectionString);
searchs.Search(this.FirstNameTextbox.Text, this.LastNameTextbox.Text,

this.EmailTextbox.Text, this.CityTextBox.Text, this.StateTextBox.Text,
this.ZipTextBox.Text, this.IssueTextBox.Text,
this.CompanyNameTextBox.Text,
Convert.ToInt32(this.SiteDropDownList.SelectedValu e.ToString()),
Convert.ToInt32(this.StatusDropDownList.SelectedVa lue.ToString()));
this.ResultsDataGrid.DataSource = searchs;

this.ResultsDataGrid.DataBind();
//Code End

This is on a click event from a web page. When the button is clicked
the
searchs object is created and populated from a sproc. Then simply set
the
datasource and bind it. This works perfectly, however, if I click the
button a 2nd, 3rd, or 4th time (usually on the 4th click) everything
works
until I get to the DataBind(). The system will hang on that line and
produce this error.

Server Error in '/' Application.

--------------------------------------------------------------------------------

Failed to open a data connection
Server=FENSQLLIBD01;database=HPCustomerSupport;use r
id=HPCustomerSupport;password=*2rT44Y* - please check the connection
string
and security settings!
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Exception: Failed to open a data connection
Server=FENSQLLIBD01;database=HPCustomerSupport;use r
id=HPCustomerSupport;password=*2rT44Y* - please check the connection
string
and security settings!

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:

[Exception: Failed to open a data connection
Server=FENSQLLIBD01;database=HPCustomerSupport;use r
id=HPCustomerSupport;password=*2rT44Y* - please check the connection
string
and security settings!]
Maritz.Learning.HP.Web.CallCenter.Tracking.searcht ask.SearchButton_Click(Object
sender, EventArgs e) in c:\inetpub\wwwroot\hplogging\search.aspx.cs:90
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl,
String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277


--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.4322.573;
ASP.NET
Version:1.1.4322.573

Has anyone ever seen anything like this?

Doug




Aug 3 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Jim Heavey | last post: by
5 posts views Thread by Joel Reinford | last post: by
7 posts views Thread by Martin | last post: by
4 posts views Thread by Dee | last post: by
1 post views Thread by Craig | last post: by
2 posts views Thread by jslaybaugh@gmail.com | last post: by
reply views Thread by sreejith.ram@gmail.com | last post: by
1 post views Thread by RN1 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.