cmd = new SqlCommand("insert into Film(FilmID,FilmName,Actor,Director,Publisher,Content,PubDate,Sort) values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox6.Text + "','" + textBox8.Text + "','" + textBox5.Text + "','" + textBox7.Text + "',)", conn);//如果不存在,进行数据库插入
去掉看看。

解决方案 »

  1.   


    /*将你 代码标红的地方的 逗号去掉..如下.
    另,你应该使用参数化语句,别拼接语句
    */ 
         cmd = new SqlCommand("insert into Film(FilmID,FilmName,Actor,Director,Publisher,Content,PubDate,Sort) values('" 
    + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" 
    + textBox4.Text + "','" + textBox6.Text + "','" + textBox8.Text + "','" 
    + textBox5.Text + "','" + textBox7.Text + "')", conn);//如果不存在,进行数据库插入
                    cmd.ExecuteNonQuery();
      

  2.   

     cmd = new SqlCommand("insert into Film(FilmID,FilmName,Actor,Director,Publisher,Content,PubDate,Sort) values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox6.Text + "','" + textBox8.Text + "','" + textBox5.Text + "','" + textBox7.Text + "',)", conn);//如果不存在,进行数据库插入上面多了一个逗号,改成这样试试: cmd = new SqlCommand("insert into Film(FilmID,FilmName,Actor,Director,Publisher,Content,PubDate,Sort) values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox6.Text + "','" + textBox8.Text + "','" + textBox5.Text + "','" + textBox7.Text + "')", conn);//如果不存在,进行数据库插入