变通处理一下,加上红字代码
forms("窗口2").show
Dim str_Conn As String = "server=voyo;uid=sa;pwd=hailun.;database=test"
Dim conn As New System.Data.SqlClient.sqlConnection(str_Conn)
conn.Open()
Dim mda As New System.Data.SqlClient.SQLDataAdapter("select * from table_1" , conn) '这里可以设置你的查询语句
Dim ds As New System.Data.DataSet()
mda.Fill(ds, "TableTemp") 'MySQLDataAdapter方法把数据放到一个新建的临时表里,这个临时表名可自定义,我这里写TableTemp
forms("窗口2").controls("Table1").Table.DataSource = ds.Tables("TableTemp") '把刚才的临时表TableTemp填充到我们的控件Table1里
conn.Colse
forms("窗口1").show
forms("窗口1").controls("Table1").Table.DataSource = forms("窗口2").controls("Table1").Table.DataTable
forms("窗口2").controls("Table1").Table.DataSource = forms("窗口1").controls("Table1").Table.DataTable