Debugging found that the return value of the SELECT statement is-1, and the following information is found:
The sqlcommand. executenonquery method executes a Transact-SQL statement on the connection and returns the number of affected rows.
Note: executenonquery can be used to perform directory operations (such as querying the database structure or creating database objects such as tables), or by executing update, insert, or delete statements, change the data in the database without using dataset.
Although executenonquery does not return any rows, any output parameters or return values mapped to parameters are filled with data. For update, insert, and delete statements, the returned value is the number of rows affected by the command. For all other types of statements, the return value is-1. If rollback occurs, the returned value is-1.
You can use the read () return value to determine, or forge an update to determineSQL= "Update users set username = username where username ='" +Username+ "'";
Http://msdn2.microsoft.com/zh-cn/library/system.data.sqlclient.sqlcommand.executenonquery (vs.80). aspx