提示“插入数据成功” ,实际在数据库中看不到?求教各位大神
代码如下:
//添加新书
private void btninsert_Click(object sender, EventArgs e)
{
if (txtauther.Text != "" && txtbookname.Text != "" && txtbookno.Text != "")
{
string str1 = ConfigurationManager.ConnectionStrings["BooksManager.Properties.Settings.LibraryManagerConnectionString"].ConnectionString;
SqlConnection coonstr = new SqlConnection(str1);
SqlCommand sqlcommand = new SqlCommand();
sqlcommand.CommandText = "insert into books (图书编号, 图书名 ,作者)values('" + txtbookno.Text.Trim().ToString() + " ','" + txtbookname.Text.Trim().ToString() + "', '" + txtauther.Text.Trim().ToString() + "')";
sqlcommand.Connection = coonstr;
coonstr.Open();
int count = sqlcommand.ExecuteNonQuery();
if (count > 0)
{
MessageBoxButtons mes = MessageBoxButtons.OK;
DialogResult dr = MessageBox.Show("添加新书成功!");
}
coonstr.Close();
}
else
{
MessageBoxButtons msg = MessageBoxButtons.OK;
DialogResult dr=MessageBox .Show ("信息输入不完整!");
}
}
我调试了一下,count=1,并且提示添加新书成功,但在数据库中却看不到,求教?