Wednesday, March 7, 2012

Help me: error on Home Page for some.

Hi there,

I'm new here and fairly new to .NET and C# too.

I've received a couple of complains about a website I've been working on thepast year or so: http://www.ipcamerademos.com/

I can open and browse the website fine, in both MS Internet Explorer andFirefox. But some people are getting some error opening up the website (homepage):

Server Error in '/' Application.


String or binary data would be truncated.
The statement has been terminated.

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.Data.SqlClient.SqlException: String or binary data would be truncated.
The statement has been terminated.

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:

[SqlException (0x80131904): String or binary data would be truncated.

The statement has been terminated.]

System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857178

System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734790

System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188

System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838

System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) +192

System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +380

System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135

ipcamerademos.index.Counter() +359

ipcamerademos.index.Page_Load(Object sender, EventArgs e) +86

System.Web.UI.Control.OnLoad(EventArgs e) +99

System.Web.UI.Control.LoadRecursive() +47

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

Anyone here gets this error and knows what would cause it? Any hints orideas - have someone experienced something similar?

Thank you all in advance,

Marcio W. Dirickson.

The website opens fine with firefox and opera but crashes everytime with ie7 on vista. What are you storing in a database or getting from a database when you load the web page?|||

Hi Ken,

Most of the home page content is from the database (the main article and all the other articles). And we store a "counter" type information from the home page as well. From what I got replies (from users and visitors) with Windows XP and IE6 also had cases of this error...

Thanks for the reply...

|||

Is your data access code in a try catch block?

|||

I was able to open the website in firefox. When I viewed the source I found this. When you fix the loading xml error I think you will solve your problem.

<td valign="top"
<!-- Right -->
<table width="223"border="0"cellspacing="0"cellpadding="0">
<!--tr>
<td>< Shop >
Loading XML: failed. Error 404x.
</td>
</tr>
<tr>
<td height="5"></td>
</tr-->
<tr>
<td>
<!-- E-newsletter -->
<table width="223"border="0"cellspacing="0"cellpadding="0">
<tr>
<td
<table width="223"border="0"cellspacing="0"cellpadding="0"bordercolor="#374B8D"bgcolor="#4761B7"style="border: 5px solid #374B8D;">
<tr>
<td><img src="/images/td_top_blue.gif"width="213"height="12"alt=""border="0"></td>
</tr>
<tr>
<td class="subtitle_blue">E-NEWSLETTERS</td>
</tr>
|||

Hi again Ken,

I've checked the XLS and wasn't that... so I added some more catch blocks and found where the error was happening: where we grabbed and stored the logs information.

public void Counter()
{
try
{
// Insert Access Log
string IP = Request.ServerVariables["REMOTE_ADDR"];
string browser = Request.ServerVariables["HTTP_USER_AGENT"];
string source = Request.ServerVariables["HTTP_REFERER"];
conn.executeSQL("INSERT INTO tbl_ipc_logs (ipl_IP, ipl_browser, ipl_source, ipl_date) VALUES ('" + IP + "', '" + browser + "', '" + source + "', '" + DateTime.Now + "')");
conn.objConnection.Close();
conn.objConnection.Dispose();
}
catch(Exception)
{
// Response.Write("Access Logs : " + e);
// Response.Flush();
}
}

With the catch the page started working.

Thank you for the help!

No comments:

Post a Comment