数据读不到数据库!!!
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;User Instance=True;AttachDBFilename=D:\My Documents\Visual Studio 2008\Projects\FirstFace\FirstFace\bin\Debug\MyDB.mdf;Integrated Security=True");con.Open();
MessageBox.Show("数据库连接成功", "好");
try
{
SqlCommand cmd = new SqlCommand("insert into Users(name,password) values('admin','admin')", con);
cmd.ExecuteNonQuery();
MessageBox.Show("添加成功!", "啊");
}
catch (Exception )
{
MessageBox.Show("出错!");
}
}
显示"数据库连接成功"," 添加成功!"但数据库中没有数据!什么原因啊?