Databind Error???

  • Thread starter Thread starter Doug Durrett
  • Start date Start date
D

Doug Durrett

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.Searchs(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.SelectedValue.ToString()),
Convert.ToInt32(this.StatusDropDownList.SelectedValue.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;user
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;user
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;user
id=HPCustomerSupport;password=*2rT44Y* - please check the connection string
and security settings!]
Maritz.Learning.HP.Web.CallCenter.Tracking.searchtask.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.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,
String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection 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
 
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 said:
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.Searchs(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.SelectedValue.ToString()),
Convert.ToInt32(this.StatusDropDownList.SelectedValue.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;user
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;user
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;user
id=HPCustomerSupport;password=*2rT44Y* - please check the connection string
and security settings!]
Maritz.Learning.HP.Web.CallCenter.Tracking.searchtask.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.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,
String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection 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
 
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_TaskActivityLastModDate",
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 said:
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 said:
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.Searchs(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.SelectedValue.ToString()),
Convert.ToInt32(this.StatusDropDownList.SelectedValue.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;user
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;user
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;user
id=HPCustomerSupport;password=*2rT44Y* - please check the connection
string
and security settings!]
Maritz.Learning.HP.Web.CallCenter.Tracking.searchtask.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.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl,
String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection 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
 
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 said:
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_TaskActivityLastModDate",
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 said:
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 said:
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.Searchs(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.SelectedValue.ToString()),
Convert.ToInt32(this.StatusDropDownList.SelectedValue.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;user
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;user
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;user
id=HPCustomerSupport;password=*2rT44Y* - please check the connection
string
and security settings!]
Maritz.Learning.HP.Web.CallCenter.Tracking.searchtask.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.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl,
String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top