想要通过asp.net设计一个页面,可以显示出在不同服务器上数据库的某个表的所有数据(表结构相同)。
展开全部
你复制代码,修改数据库连接,以及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()
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()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询