|
|
Mời bạn đăng ký để giao lưu kết bạn nhé <3
Bạn phải đăng nhập để xem được nội dung, nếu bạn chưa có tài khoản? hãy Đăng ký
x
Tôi có 1 đoạn mã sau:
string url, ConnectionString;
private DataSet Ds;
OleDbConnection Connection;
private OleDbDataAdapter odbAdapter;
private void Form1_Load(object sender, EventArgs e)
{
url = Application.StartupPath + "\\";
ConnectionString = "provider=Microsoft.JET.OLEDB.4.0; " + "data source =" + url + "vom.mdb";
Connection = new OleDbConnection(ConnectionString);
Ds = new DataSet();
string CommandString = "Select * from SoLieuChung";
odbAdapter = new OleDbDataAdapter(CommandString, ConnectionString);
odbAdapter.Fill(Ds, "SoLieuChung");
}
private void button_Luu_Click(object sender, EventArgs e)
{
Luu_NhapSoLieu(Ds.Tables["SoLieuChung"]);
}
private void Luu_NhapSoLieu(DataTable dt)
{
DataRow targetRow = dt.Rows[0];
targetRow[3] = Convert.ToDouble(dTextBox.Text);
odbAdapter.Update(dt); //lỗi ở chỗ này
}
Khi chạy thực hiện hàm Luu_NhapSoLieu thì báo lỗi :"Update requires a valid UpdateCommand when passed DataRow collection with modified rows"
Ai có thể gúip tôi update vào CSDL được ko?Thanks |
|