回答一下吧 我快急死了
如果是这样,是因为你没有赋予一个更新查询的COMMAND
针对你的代码,可以这样修改一下。
建议你找一个例子,仔细啃一啃,然后再动手写。写的第一个项目,应当与例子相近,或者说,你能丢下例子,写一个与例子一样的项目,然后再开发自已的项目吧。
程序代码:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Str As String = "insert into zuankong(名称) values('名称')" '插入一条记录 Dim conn As OleDb.OleDbConnection = New OleDb.OleDbConnection conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & System.Windows.Forms.Application.StartupPath & "\zkshujuku.mdb;" conn.Open() '打开连接 Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(Str, conn) cmd.ExecuteNonQuery() '执行插入数据 Str = "select * from zuankong" '更新查询 Dim da As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter(Str, conn) da.Fill(ZkshujukuDataSet, "zuankong") DataGridView1.DataSource = ZkshujukuDataSet.Tables(0) '更换datagridview1的数据源 DataGridView1.Refresh() conn.Close() End Sub