Dim conn As System.Data.SQLite.SQLiteConnection
conn = New SQLiteConnection("Data Source=d:\northwindEF.db;Pooling=true;FailIfMissing=false")
conn.Open()
Dim sa As New SQLiteDataAdapter("select * from customers ", conn)
Dim ds As New System.Data.DataSet
sa.Fill(ds)
Dim mytable As New System.Data.DataTable
mytable = ds.Tables(0)
Me.DataGridView1.DataSource = mytable
Me.DataGridView1.Refresh()
ds.Tables(0).Rows(0).Item(1) = "88"
Me.DataGridView1.Refresh()
sa.Update(ds)
錯誤提示
System.InvalidOperationException:“當傳遞具有已修改行的 DataRow 集合時,更新要求有效的 UpdateCommand。”
我用oledb訪問acess資料庫時候 沒出過這個錯誤
uj5u.com熱心網友回復:
okDim builder As SQLiteCommandBuilder = New SQLiteCommandBuilder(sa)
uj5u.com熱心網友回復:
我一般是直接定義DataTable 的,然后一fill就ok啦。DataTable dt = new DataTable();
adapter.Fill(dt);
DataGridView1.DataSource = dt;
當然SqlDataAdapter和你上面的一樣。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/69560.html
標籤:VB.NET
上一篇:C# 串口通訊
