1. Detected request. Form values that are potentially dangerous
Cause:
(1) The validaterequest attribute is not correctly set on the data submission page or webconfig.
(2) Two <form>
Solution:
Solution 1: add this sentence to the. aspx file header: <% @ page validaterequest = "false" %>
Solution 2: Modify the Web. config file:
<Configuration>
<System. Web>
<Pages validaterequest = "false"/>
</System. Web>
</Configuration>
Because the default value of validaterequest is true. Set it to false.
2. "An invalid read attempt is made when no data exists" SOLUTION
Cause:
The returned sqldatareader does not have a data record, but does not perform record judgment. Null Value returned
Add judgment: If (reader. Read () {textname. Text =
Reader ["fieldname"]. tostring ();}
3. The data is empty. This method or attribute cannot be called for null values.
Cause:
If the object is null, the method of calling the object, for example, tostring (), must have an error. Generally, the value of the database field is null.
Data controls such as grideview often appear
Solution: Therefore, it is recommended to perform null processing.
4. The fieldcount attempt is invalid when the reader is disabled.
Cause:
After sqldatareader is used to bind data, the connection object is closed ().
Similar
Public sqldatareader getsomething ()
{
Conn. open ();
Sqldatareader reader =
Sqlcmd. excecutreader (commandbehavior. closeconnection ));
Conn. Close (); // occur error here
Return reader;
}
This method is called during binding to specify the data source. If you use this method, you need to disable re in the call function.
In this way, the conn can be automatically disabled.
If sqldataadapter and dataset are used, remove the explicit call to disable Conn. Or in finally
.
5. The path cannot be mapped.
Cause: it may be because the path configuration in webconfig is incorrect. This problem is prominent in FCKeditor configuration.
<Add key = "FCKeditor: basepath" value = "~ /Admin/FCKeditor/"/>
<Add key = "FCKeditor: userfilespath" value = "/userfiles/"/>
6. Unreachable code Detected
Cause:
Generally, throw or return is used for exception handling or return values. It may be that the position is put in front, resulting in subsequent code execution.
Solution:
Put the throw or return statement to the last row of the agent.
7. The index is out of range. Must be non-negative and smaller than the set size
Cause:
(1). datakeyfield is not set to the unique field corresponding to the database (generally the primary key)
(2). Maid> E. Item. Cells
Solution:
(1). Set datakeyfield
(2) Add the judgment statement maid. Count (DataGrid can be another similar Server Control)
8. Error: Part of path "C: \" is not found.
Note:
An error occurred while executing the current Web request. Check the stack trace information for details about the error and the source of the error in the code.
Exception details: system. Io. directorynotfoundexception: Part of the path "C: \" is not found.
Solution:
Adding the Users Group read permission to drive C can be accessed. However, due to server security issues, the Users group permissions should be removed. Successive problems are shown in different error methods, as mentioned below, we will solve the problem one by one.
9. The data source does not support data paging on the server.
Solution:
Do not use datareader, instead use dataset: or use custom paging mode. Do not use the paging function provided by vs.net.
Oledbdataadapter da = new oledbdataadapter (SQL, connection );
Dataset ds2 = new dataset ();
Da. Fill (ds2, "news ");
Gridview1.datasource = DS2;
Gridview1.databind ();
10. The object name '*****' is invalid.
Cause: the current database does not have the *** table, or the current database connection account does not have the operation permission for this object.
Solution: solution to cause 1: Check whether the name of the called table is incorrectly written in the program or whether the SQL database contains the table cause 2 you called: change the owner of all objects in your database to DBO.
Solution (this solution comes from the network and is effective after experiments) as follows:
Use your account to connect to the query analyzer and run the following SQL statement:
You can use sp_changedbowner to change the database owner.
Method 1: Right-click the table and choose design table from the shortcut menu. In the previous small icon, click the last "condition constraint" and click the "table" page to change the owner. (If there is no small icon with constraints, you can right-click to see a "Check constraint" option)
Method 2: Execute the script directly, log on to the database with a system account or a super user, and then execute the following statement:
Sp_configure 'Allow updates', '1' go reconfigure with override go update sysobjects set UID = 1 where uid <> 1 go sp_configure 'Allow updates ', '0' go reconfigure with override/* batch replacement
Declare TB cursor local for select 'SP _ changeobjectowner '[' + Replace (user_name (UID), ']', ']') + ']. ['+ Replace (name,'] ','] ') +'] '', ''dbo' 'from sysobjects where xtype in ('U ', 'V', 'P', 'tr ', 'fn', 'if', 'tf') and status> = 0 open TB declare @ s nvarchar (4000) fetch TB into @ s while @ fetch_status = 0 begin exec (@ s) Fetch TB into @ s end close TB deallocate TB go
*/