我正在尝试将数据插入数据库。连接工作正常。但是我无法插入数据,我也不知道为什么。该表只是没有得到更新。
string ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\Kaushalya\\Documents\\NewAgain.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
SqlCommand cmd = new SqlCommand("Insert into Tabel1(name) VALUES (@UserName);",conn);
cmd.Parameters.Add(new SqlParameter("@UserName", Convert.ToInt32(0)));
测试时连接正常。但是,我无法对数据库执行任何操作。
最佳答案
关于c# - 数据库中没有发生数据插入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6021260/