我用了ADO Data控件来操作DataGrid显示数据,但是在修改和更新数据库时候,出现了“对象关闭时,不允许操作”的错误。代码如下:
upStr = "update pathtable set class='" & Text1.Text & "' where circuitname='" & primaryKey & "'"
Adodc1.RecordSource = upStr
Adodc1.Refresh如何修改啊,请大家帮帮忙!
upStr = "update pathtable set class='" & Text1.Text & "' where circuitname='" & primaryKey & "'"
Adodc1.RecordSource = upStr
Adodc1.Refresh如何修改啊,请大家帮帮忙!
有可能是ADO代码的连接没有open如cnn.open
那么在下一个要应用ado连接时 必须用adodc.open建立连接
好像直接用ado对象执行不了sql语句,你应该这样建立一个用来更新的按钮 在单击事件里
dim cnn as connection
set cnn=new connection
dim upstr as string
upStr = "update pathtable set class='" & Text1.Text & "' where circuitname='" & primaryKey & "'"
cnn.Execute upstr