VB+SQL中datagrid1控件绑定ADODC1更新数据后adodc1.refresh数据又还原了,为什么?有什么办法解决
VB+SQL中datagrid1控件绑定ADODC1.在DataGrid1中更新数据后马上adodc1.refresh数据又还原了,为什么?有什么办法解决....
VB+SQL中datagrid1控件绑定ADODC1.在DataGrid1中更新数据后马上adodc1.refresh数据又还原了,为什么?有什么办法解决.
展开
2个回答
展开全部
不用绑定,用代码就可以了。不要将adodc1与datagrid1绑定。
Option Explicit
Public conn As New ADODB.Connection
Public rs As ADODB.Recordset
Public sql As String
Public Sub connserver()
Set conn = New Connection
conn.ConnectionString = "Driver={sql server};server=127.0.0.1,7788;uid=sa;pwd=admin;database=db_goods"
conn.ConnectionTimeout = 10
conn.Open
End Sub
Private Sub Command1_Click()
Adodc1.ConnectionString = conn
Adodc1.RecordSource = "select * from tb_bmxx order by bmxx_id"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
DataGrid1.Refresh
End Sub
Private Sub Form_Load()
Call connserver
End Sub
Option Explicit
Public conn As New ADODB.Connection
Public rs As ADODB.Recordset
Public sql As String
Public Sub connserver()
Set conn = New Connection
conn.ConnectionString = "Driver={sql server};server=127.0.0.1,7788;uid=sa;pwd=admin;database=db_goods"
conn.ConnectionTimeout = 10
conn.Open
End Sub
Private Sub Command1_Click()
Adodc1.ConnectionString = conn
Adodc1.RecordSource = "select * from tb_bmxx order by bmxx_id"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
DataGrid1.Refresh
End Sub
Private Sub Form_Load()
Call connserver
End Sub
网易云信
2023-12-06 广告
2023-12-06 广告
UIkit是一套轻量级、模块化且易于使用的开源UI组件库,由YOOtheme团队开发。它提供了丰富的界面元素,包括按钮、表单、表格、对话框、滑块、下拉菜单、选项卡等等,适用于各种类型的网站和应用程序。UIkit还支持响应式设计,可以根据不同...
点击进入详情页
本回答由网易云信提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询