vb.net 中 datagridview 控件, 怎么让它查询的结果递增(累加)!
输入条件后,第一次查询,datagridview中就显示结果,当按第二次查询时,第一次的查询结果就没了,只有显示第二次查询的结果!我想让它显示我每次查的结果都在上边显示着...
输入条件后,第一次查询,datagridview 中就显示结果,当按第二次查询时,第一次的查询结果就没了,只有显示第二次查询的结果! 我想让它显示我每次查的结果都在上边显示着! 求会的高手回答,在线等!
是vb.net的 C/S 程序哦 不是网站 展开
是vb.net的 C/S 程序哦 不是网站 展开
2个回答
展开全部
这是我刚刚试验过的 绝对可行
Imports System.Data.SqlClient
Public Class Form1
Private DataTable1 As New DataTable '设成全局变量
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Sql1 As New SqlConnection
Dim CB As New SqlConnectionStringBuilder
CB.DataSource = "MICROSOF-91C849\SQLEXPRESS" '数据库服务器名称
CB.InitialCatalog = "test" '数据库名称
CB.UserID = "ww"
CB.Password = "123456"
Sql1.ConnectionString = CB.ConnectionString
Sql1.Open()
Dim Adp1 As New SqlDataAdapter("Select * From FileTemp Where Name = '1'", Sql1) '第一个查询语句
Adp1.Fill(DataTable1)
Me.DataGridView1.DataSource = DataTable1
Sql1.Close()
Sql1.Dispose()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Sql1 As New SqlConnection
Dim CB As New SqlConnectionStringBuilder
CB.DataSource = "MICROSOF-91C849\SQLEXPRESS"
CB.InitialCatalog = "test"
CB.UserID = "ww"
CB.Password = "123456"
Sql1.ConnectionString = CB.ConnectionString
Sql1.Open()
Dim Adp1 As New SqlDataAdapter("Select * From FileTemp Where Name = '2'", Sql1) '第二个查询语句
Adp1.Fill(DataTable1)
Me.DataGridView1.DataSource = DataTable1
End Sub
End Class
Imports System.Data.SqlClient
Public Class Form1
Private DataTable1 As New DataTable '设成全局变量
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Sql1 As New SqlConnection
Dim CB As New SqlConnectionStringBuilder
CB.DataSource = "MICROSOF-91C849\SQLEXPRESS" '数据库服务器名称
CB.InitialCatalog = "test" '数据库名称
CB.UserID = "ww"
CB.Password = "123456"
Sql1.ConnectionString = CB.ConnectionString
Sql1.Open()
Dim Adp1 As New SqlDataAdapter("Select * From FileTemp Where Name = '1'", Sql1) '第一个查询语句
Adp1.Fill(DataTable1)
Me.DataGridView1.DataSource = DataTable1
Sql1.Close()
Sql1.Dispose()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Sql1 As New SqlConnection
Dim CB As New SqlConnectionStringBuilder
CB.DataSource = "MICROSOF-91C849\SQLEXPRESS"
CB.InitialCatalog = "test"
CB.UserID = "ww"
CB.Password = "123456"
Sql1.ConnectionString = CB.ConnectionString
Sql1.Open()
Dim Adp1 As New SqlDataAdapter("Select * From FileTemp Where Name = '2'", Sql1) '第二个查询语句
Adp1.Fill(DataTable1)
Me.DataGridView1.DataSource = DataTable1
End Sub
End Class
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询