我有一个将数据插入数据库的表单。asp.net SQL Server插入语句tidyup +错误
有一些不总是需要的领域。 当我在代码中留下这些空白时,我收到一条错误消息。
列名或提供的值的数量与表 的定义不匹配。
这是我如何进行数据库设置。 SQL Server 2008
[youthclubid]
[youthclubname]
[description]
[address1]
[address2]
[county]
[postcode]
[email]
[phone]
这是我连接到数据库并执行插入的代码。
connection.Open();
cmd = new SqlCommand("insert into youthclublist values ('" + youthclubname.Text + "', '" + description.Text + "','" + address1.Text + "','" + address2.Text + "', '" + county.Text + "', '" + postcode.Text + "', '" + email.Text + "', '" + phone.Text + "')", connection);
cmd.ExecuteNonQuery();
你取得了你的PK列`youthclubid`为`身份=是吗? http://msdn.microsoft.com/en-us/library/ms177173.aspx – 2011-12-15 10:20:59
http://xkcd.com/327/:D – 2011-12-15 10:44:15