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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询