修改了ACCESS后如何实时的反映出来?

msnchina0 2006-07-15 10:41:33
朋友们,我每次修改了ACCESS后, 还需要把程序关了才重新打开才能看到修改后的结果,有没有好的方法可以修改后实时的看到结果?
...全文
369 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
xg15123 2006-07-15
  • 打赏
  • 举报
回复
谢谢你帮我分析一下我到底错在哪里!!!!!!!
xg15123 2006-07-15
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Set db = DBEngine.OpenDatabase(App.Path & "/db1.mdb")
Set rs = db.OpenRecordset("SELECT * FROM web2", dbOpenDynaset)
rs.MoveLast
b = rs!upid
rs.MoveFirst
a = rs!upid
On Error Resume Next
For c = a To b
txtsend.Text = rs!ip
Load tcpcl(tcpcl.UBound + 1)
tcpcl(tcpcl.UBound).LocalPort = 0
tcpcl(tcpcl.UBound).RemoteHost = txtsend.Text
tcpcl(tcpcl.UBound).RemotePort = 15124
tcpcl(tcpcl.UBound).Close
tcpcl(tcpcl.UBound).Connect
Sleep (1000)
DoEvents
If txtoutput.Text <> "" Then
If rs!message = "" Or IsNull(rs!message) Then
rs.Edit
rs!message = txtoutput.Text
rs.Update
ElseIf rs!message = txtoutput.Text Then
MsgBox "正常"
End If
txtoutput.Text = ""
End If
rs.MoveNext
Next
rs.Close
db.Close
MsgBox "ok"
End Sub
tripman 2006-07-15
  • 打赏
  • 举报
回复
rs打开了吗?例如:g_CONNECT是连接串
rs.Open "select * from table1", g_CONNECT, adOpenKeyset, adLockOptimistic

不如干脆把代码贴出来
xg15123 2006-07-15
  • 打赏
  • 举报
回复
哦,这没有,DataGrid1.DataSource 我设置的是Adodc1,好果改成Set DataGrid1.DataSource = rs后,DataGrid1不显示内容,是我放错地方了或是理解错了意思了吗?对不起,我是个初学者,不好意思.......
tripman 2006-07-15
  • 打赏
  • 举报
回复
你有没有绑定?在窗口Load里绑定
Set DataGrid1.DataSource = rs
...
rs!message = txtoutput.Text
这样DataGrid1就可以看到改变了
xg15123 2006-07-15
  • 打赏
  • 举报
回复
对不起,还是不行啊,还是得重起以后才能看到....
tripman 2006-07-15
  • 打赏
  • 举报
回复
rs.Edit
rs!message = txtoutput.Text
rs.Update
DataGrid1.Refresh

xg15123 2006-07-15
  • 打赏
  • 举报
回复
rs.Edit
rs!message = txtoutput.Text
DataGrid1.Refresh
rs.Update
想让它在DataGrid1中实时显示,是不是我以上的代码中写错什么了?为什么不能实时显示啊?
tripman 2006-07-15
  • 打赏
  • 举报
回复
在哪里显示?如果是DataGird绑定应该rs!message = txtoutput.Text之后就会显示,如果没有绑定重新Open一下rs
xg15123 2006-07-15
  • 打赏
  • 举报
回复
帮顶!!!!!!!!!!!!!1
msnchina0 2006-07-15
  • 打赏
  • 举报
回复
rs.Edit
rs!message = txtoutput.Text
rs.Update
我这样修改完的.用rs.refresh,说未找到方法或数据成员?
一笑拔剑 2006-07-15
  • 打赏
  • 举报
回复
datagird adodc 等等都支持这个方法
tripman 2006-07-15
  • 打赏
  • 举报
回复
在哪里修改的?刷新一下
一笑拔剑 2006-07-15
  • 打赏
  • 举报
回复
你是用什么修改的?
一般调用以下Refresh就可以立即看见效果
比如data1.Refresh
zhoujk 2006-07-15
  • 打赏
  • 举报
回复
我没遇到过这种问题,也是用代码来设置的数据库,随改随看呀
一笑拔剑 2006-07-15
  • 打赏
  • 举报
回复
我同意tripman(当牛粪遇上鲜花) 的说法

如果你一定要这样操作的就用我的代码
一笑拔剑 2006-07-15
  • 打赏
  • 举报
回复
你直接用adodc操作不就方便多了
需要刷新的时候
Adodc1.RecordSet.Close
Adodc1.RecordSource = "你的连接字符串"
Adodc1.Recordset.Open
set datagrid1.recordsource=adodc1.recordset
DataGrid1.Refresh
tripman 2006-07-15
  • 打赏
  • 举报
回复
既然DataGrid1.DataSource绑定Adodc1为什么不用Adodc1?把rs换成Adodc1

Private Sub Command1_Click()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\test.mdb;User Id=;Password=;"
dodc1.RecordSource = "SELECT * FROM web2"
Adodc1.Refresh
Adodc1.Recordset.MoveLast
b = Adodc1.Recordset("upid")
Adodc1.Recordset.MoveFirst
a = Adodc1.Recordset("upid")
On Error Resume Next
For c = a To b
txtsend.Text = Adodc1.Recordset("ip")
Load tcpcl(tcpcl.UBound + 1)
tcpcl(tcpcl.UBound).LocalPort = 0
tcpcl(tcpcl.UBound).RemoteHost = txtsend.Text
tcpcl(tcpcl.UBound).RemotePort = 15124
tcpcl(tcpcl.UBound).Close
tcpcl(tcpcl.UBound).Connect
Sleep (1000)
DoEvents
If txtoutput.Text <> "" Then
If Adodc1.Recordset("message") = "" Or IsNull(Adodc1.Recordset("message")) Then
Adodc1.Recordset.Edit
Adodc1.Recordset("message") = txtoutput.Text
Adodc1.Recordset.Update
ElseIf Adodc1.Recordset("message") = txtoutput.Text Then
MsgBox "正常"
End If
txtoutput.Text = ""
End If
Adodc1.Recordset.MoveNext
Next
MsgBox "ok"
End Sub

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧