CodePudding user response:
Post your code, this can only see the CommandText problem, look at the picture insert into values are you became a valuerCodePudding 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 SqlHelperCodePudding user response:
Some open dialog box below the first row: to view detailed informationCodePudding 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 youCodePudding user response:
The https://gitee.com/dlgcy/dotnetcodes/blob/dlgcy/DotNet.Utilities/database operations/used/SqlServerHelper. CsBy 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 specifiedCodePudding user response:
https://blog.csdn.net/yenange/article/details/52936643Look at my blog,
CodePudding user response: