你复制代码,修改数据库连接,以及sqlcommand,就可以实现
Dim ds As DataSet = New DataSet()
Dim conn As SqlConnection = New SqlConnection("server=FZ545X1\SQLEXPRESS;integrated security=true;database=demo")
Dim da As SqlDataAdapter = New SqlDataAdapter()
Dim cmd As SqlCommand = New SqlCommand("select * from dbo.class", conn)
conn.Open()
da.SelectCommand = cmd
da.Fill(ds, "table")
conn.Close()
Dim conn2 As SqlConnection = New SqlConnection("server=FZ545X1\SQLEXPRESS;integrated security=true;database=demo2")
Dim da2 As SqlDataAdapter = New SqlDataAdapter()
Dim cmd2 As SqlCommand = New SqlCommand("select * from dbo.class", conn)
conn2.Open()
da2.SelectCommand = cmd
da2.Fill(ds, "table")
conn2.Close()
Me.GridView1.DataSource = ds
Me.GridView1.DataBind()