Column does not belong to the table-summary of issues that may occur

Source: Internet
Author: User

Personal feelings can be associated with database blocking or memory leaks.

Business:

Characteristics of the anomaly:
One: The biggest feature is randomness. Will suddenly error, perhaps when, it is possible that you next click, or refresh the page, in short, there is a connection to the database (query, bound data control).
Second: The diversity of error. After an error, all kinds of errors are sprayed well type, such as "column does not belong to the table", "can not find table 0", "Data conversion is unsuccessful" and so on, but all are related to database data.
Three: The duration is relatively short. Many page error, refresh several times, or wait a while, and normal, and can use, but may next click, Refresh, and then error
Four: The more people use, the worse the network situation, the more frequent. My system within the company several developers test no problem, but on-line, the customer company a lot of people use, there is constantly this mistake. And, there are a few days the network is better, did not happen this mistake, I thought changed dbhelper has been fixed, but these days and continue to error.

1.

Dharma Name: GetList exception Information: column "ProductId" does not belong to table
LZ My company's website does not know how many times, I have also sent such a post, but at that time I resolved
The reason is that the problem of global variables, because my SQL is stitching, and in some methods set the value of that global variable,
Then the second call to the other method, because the field is set, so wrong, and finally I changed the global variable to a local variable
There's nothing wrong with that.

NND, after a while, the problem is that the global variable is still the problem, but the whole project has no global variables
This problem has not been solved, but from my log records, 1, my project's data layer has logged the Exception log, in the page global.aspx also recorded the Exception log. And the data layer is thrown after logging, so the normal data layer error
Then there will be 2 log records, one is the data layer, the log has the value of the record parameter, and the other is the page, the log directly records the exception information, but each time only the page log, so the suspicion is related to data binding

2.

SqlConnection do not use global or static or singleton mode, otherwise there will be different processes into the common connection situation, especially in the web environment, which will lead to the user to obtain the dataset is incorrect, which raises the problem I raised above, the solution is to do the number According to the connected place new connection to use, after close, so you can avoid a similar to "xxxxx does not belong to table" a series of problems ...

3.

This problem may be due to the concurrency of the data taken out of the problem, it is difficult to find the problem, so,
Finally, in this often error-prone place, add a try catch, and then add a log in the catch to list all the fields of the table to see what it is.

4.

Check the log in the database, the error will affect the application pool, to restart
Whether it is a concurrency operation issue

5.

Oh, it should be concurrency problems resulting in data timeouts
You can enlarge the connection pool of the database a bit.

6.

It is suggested that LZ will add a log on the line, because things on the line sometimes error is difficult to track, then you see the problem is not comprehensive.
Before because the Web site after the problem, the eldest brother to reason, I said I do not know, later he let me add log tracking.
In this case, problems can be documented. I'm using log4net now.

7.

Make sure that the errors you quoted are not the result of the connection timeout. The bottom line is that the problem with your code is still in the final analysis.
1. Log record SQL statements and connection strings
2. Check if there are any spam data
3. Check the code. (Database connection, your DBHelper, query statement)

8,
Database ADO connection operation is not correct, I also encountered such a problem, the original Dbhelp class used is a static connection object, now do not use static, in use when all re-create objects, problem solving.  
code as follows:  
public static int ExecuteCommand (string safesql)  
         { 
            using (SqlConnection Connection = new SqlConnection (connectionString))  
             {

SqlCommand cmd = new SqlCommand (Safesql, Connection);
int result = cmd. ExecuteNonQuery ();
Connection.close ();
return result;
}
}

Column does not belong to the table-summary of issues that may occur

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.