Home > Net >  CommandText property ACTS has not been initialized
CommandText property ACTS has not been initialized

Time:11-09

To solve the

CodePudding user response:

Post your code, this can only see the CommandText problem, look at the picture insert into values are you became a valuer

CodePudding user response:

Code written more embarrassing, seemingly saved a number of lines, but the problem is bad to debug, write error that line breaks, to execute the command. The first ExecuteNonQuery, results will be assigned to a variable, and then the transformation, the final judgment, so better debugging,

See the error message, it should be the command is not set connection, the attribute without initialization,

CodePudding user response:

This super is not standard, is also not good debugging, or write a SqlHelper

CodePudding user response:

Some open dialog box below the first row: to view detailed information

CodePudding user response:

Try not to write combination line, separate each row, the error message can clearly know the problem, solve the bug is convenient;

CodePudding user response:

Your code logic has a problem, perform the if (name=="" first... ), pop-up messagebox, you ordered, will continue to execute that sqlcommand generated code, while the SQL and no assignment, so appeared the commandtext property ACTS not assignment errors,
The sqlcommand code moved to behind the else inside, and the SQL to check your spelling (1 # said the value is written by you valuer)

CodePudding user response:

Resolved thank you

CodePudding user response:

The https://gitee.com/dlgcy/dotnetcodes/blob/dlgcy/DotNet.Utilities/database operations/used/SqlServerHelper. Cs

By building, who help to take a look at my this helper classes has no problem

CodePudding user response:

The above SQL have parameters, is not specified

CodePudding user response:

https://blog.csdn.net/yenange/article/details/52936643

Look at my blog,

CodePudding user response:

refer to the eighth floor independent observers response:
https://gitee.com/dlgcy/dotnetcodes/blob/dlgcy/DotNet.Utilities/database operations/used/SqlServerHelper cs

Floor, who help to look at me this class has no problem help



Can look at the automatic releasing mechanism, do not need frequent close the database

CodePudding user response:

11 references, small white lindsey white reply:
Quote: refer to the eighth floor of the independent observers reply:
https://gitee.com/dlgcy/dotnetcodes/blob/dlgcy/DotNet.Utilities/database operations/used/SqlServerHelper. Cs

Floor, who help to look at me this class has no problem help



May have a look automatic releasing mechanism, do not need frequent shut down database


You mean the using?

CodePudding user response:

Sqlconnection no connection string?
  •  Tags:  
  • C#
  • Related