Using the three-layer Dal to manipulate the database is, if the database stored procedures do not have your defined parameters, will appear: "The scalar variable must be declared" @ "error, because through DB. This parameter is not in the database when Addinparameter. The parameters of the function can use the name of the column in the table as much as possible without the error. You can also define the parameters to use by storing procedures in the database. Eg://////whether the record///public bool Exists (int datatype_id, string ddictnum) {Database db = Databasefactory.creat Edatabase (); StringBuilder strSQL = new StringBuilder (); Strsql.append ("SELECT count (1) from t_ddict where datatype_id= @DataType_Id and ddictnum= @DdictNum"); DbCommand DbCommand = db. Getsqlstringcommand (Strsql.tostring ()); Db. Addinparameter (DbCommand, "datatype_id", Dbtype.int32, datatype_id); Db. Addinparameter (DbCommand, "Ddictnum", dbtype.string, Ddictnum); Database tables:
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