ASP。NET SQL

皮熊熊 皮熊熊 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我写了段程序,往数据库中加入数据,程序执行完了,也弹出了MESSAGEBOX,但是数据库中显示表数据没有,这是为什么




private void button1_Click(object sender, EventArgs e)
{
string dateDir = AppDomain.CurrentDomain.BaseDirectory;
if (dateDir.EndsWith(@"\bin\Debug\") || dateDir.EndsWith(@"\bin\Release\"))
{
dateDir = System.IO.Directory.GetParent(dateDir).Parent.Parent.FullName;
AppDomain.CurrentDomain.SetData("DateDirectory", dateDir);
}
using (SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;
AttachDbFilename=|DataDirectory|\软件工程.mdf;Integrated Security=True;User Instance=True"))
{
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "insert into bookshop(ID,name,writer,price,publisher,[key],rest,sold,kind) values ('1','明白之神','赵恒(译)','26','中信出版社','162869351','34','34','社科')";
cmd.ExecuteNonQuery();
}
conn.Close();
}

MessageBox.Show("OK");

}
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
皮熊熊
其它技术问题 3,881 成员 9,044 内容