我有以下代码插入问题
public class BaseController : Controller
{
SqlConnection con;
DataSet dsl;
SqlDataAdapter da;
public ActionResult Index()
{
con = new SqlConnection();
dsl = new DataSet();
con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\tbl.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
con.Open();
string sql = "SELECT * From tbl_fb";
//string sql = "INSERT INTO tbl_fb (Ime) VALUES ('aaa3')";
da = new SqlDataAdapter(sql, con);
da.Fill(dsl, "fb");
SqlCommandBuilder cb;
cb = new SqlCommandBuilder(da);
DataRow dRow = dsl.Tables["fb"].NewRow();
dRow[1] = "some text";
dsl.Tables["fb"].Rows.Add(dRow);
da.Update(dsl, "fb");
}
}
此代码,应该保存“aaa3”串“IME”行。或者排列为1(这是Ime - 第二行)的“某些文本”字符串。
但它不工作。有人知道为什么。我试过this tutorial。
谢谢。
任何错误?异常?你有没有跟踪,发生了什么?所有比“但它不工作”更有用的信息。 – RPM1984 2011-01-11 11:23:03
没有错误,没有例外,似乎都很好 – Sebastjan 2011-01-11 11:30:45