Beef Brisket Press Release System-Error collection (1)

Source: Internet
Author: User
Tags class generator

in the study of Beef brisket news release system encountered some errors, and came up with some solutions, share to everyone.

           error One,because of the DAL. Sqlhelper.test () "Return void, no object expression after return keyworde:\ accelerated \ Beef Brisket Press release system \dal\sqlhelper.cs - -DAL

The code is as follows:

Public  Void Test ()        {            string [email protected] "server=qiwei; database=newssystem; uid=sa; pwd=123456";            SqlConnection conn=new SqlConnection (connstr);            String sql = "INSERT into category (name) values (' Nfdsa ')";            SqlCommand cmd=new SqlCommand (sql,conn);            int Res=cmd. ExecuteNonQuery ();            return res;
Analysis and Solutions:The cause of this error is the return value problem, which is known by "return res", and the returned void is converted to int.

error two,

Analysis and Resolution: This occurs because code execution requires that the database be opened, but there are no commands open and closed in the code. Add in.

The code is as follows:

public  int Test ()        {            string [email protected] "server=qiwei; database=newssystem; uid=sa; pwd=123456";            SqlConnection conn=new SqlConnection (connstr);            <span style= "color: #ff0000;" >conn. Open ();</span>            String sql = "INSERT INTO category" (name) VALUES (' Nfdsa ') ";            SqlCommand cmd=new SqlCommand (sql,conn);            int Res=cmd. ExecuteNonQuery ();            <span style= "color: #ff0000;" >conn. Close ();</span>            return res;        }
  error Three,


Analysis and Solution: Database execution error, indicating that the database is out of the question. After analysis, it is because the input word length exceeds the design value of the data. Change the length of the corresponding data in the database to a larger size.

error Four,SQL statement can execute normally, but display object name is invalid


Analysis and solution: usually because the table structure was modified on the way to the query.

Workaround:

1. Back up your query statement

2. Close the Query tab

3. Refresh database, table

4, re-establish the query, paste the statement can be.

error Five,

Analysis and Solution: accidentally double-clicked the Text1 control, the corresponding code appears. This error occurs when the code is deleted. So the textchanged part of the contents of the deletion will be OK.

Error Six, the file generated by the Entity class generator cannot be referenced by the DAL.

Analytics and Solutions: Files that are typically generated by the class builder, although shown in the Solution Explorer, are not included in the project and are set up.

Error seven,INSERT statement with FOREIGN KEY constraint "fk_news_category" conflict. The conflict occurs in the database "Newssystem", the Table "Dbo.category", and the column ' ID '.

Analysis and Solution: The database table has a foreign key association, so there are one by one corresponding relationships. If not, adding the table contents and deleting the table contents will be an error.

error eight , msg 512, Level 16, State 1, procedure Trigcategorydelete, line 14th

the subquery returns more than one value. This is not allowed when subqueries are followed by =,! =, <, <=, >, >=, or when the subquery is used as an expression. statement has been terminated. The code is as follows:
ALTER TRIGGER [dbo]. [Trigcategorydelete]   On  [dbo].[ Category]   instead of Deleteas BEGIN    declare @caId int    select @caId =id from deleted     --delete comment    Delete Comment Where newsid= (select NewsId from news where [email protected])       //= number changed to in    --delete press    Delete news where [E Mail protected]     --Delete category Delete categories    where ID [email protected] END
Analysis and Solutions: basic database knowledge. To delete a comment, change the line "=" to "in".
error Nine , error 1"ExecuteQuery" method does not have any overloads with 1 parameters e:\ accelerated \ in-process \ Beef Brisket Press release system \dal\categorydao.cs DAL Public DataTable selectall ()        { datatable dt = new DataTable(); string sql = "SELECT * from category";dt = SqlHelper. ExecuteQuery (SQL); return DT;

Analysis and Solution: The error indicates that the corresponding parameters are missing. This allows you to see what parameters are available in the corresponding executequery in the SqlHelper.

Summary: It's not scary to have an error, but it's scary to be afraid. Every mistake is a rare learning opportunity to be solved by means of a method. Then you are deeply impressed with a piece of knowledge. Programmers are constantly making mistakes and growing up in programming!

Beef Brisket Press Release System-Error collection (1)

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.