当我从组合框中选择项目时,我让项目有组合框项目它是来自同一个表格中不同列的数据视图中的视图数据 问题是当我从组合框数据网格查看数据中选择项目时,当我选择其他项目形式组合框数据网格视图新列与旧列
这是我的代码:
Dim sqlconn As New SqlConnection(con)
Dim comm As New SqlCommand
'Dim comm2 As New SqlCommand
Dim sql As String = "select * from entsab"
Dim adpt As New SqlDataAdapter(Sql, con)
Dim ds As New DataSet()
Dim dr As SqlDataReader
Dim dr2 As SqlDataReader
Dim dt As New DataTable
Private Sub ComboBox2_SelectedValueChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedValueChanged, ComboBox3.SelectedValueChanged
Select Case ComboBox2.SelectedItem
Case ComboBox2.Items.Item(0) '1
dt.Clear()
Dim comm2 As New SqlCommand
comm2.CommandText = Nothing
DGV1.Refresh()
comm2.CommandText = "select l1,sub_code,sub_name,houres from sub_with_sct where sction_ID=1"
comm2.Connection = sqlconn
sqlconn.Open()
dr2 = comm2.ExecuteReader
dt.Load(dr2)
DGV1.AutoGenerateColumns = True
DGV1.DataSource = dt
DGV1.Refresh()
sqlconn.Close()
DGV1.Visible = True
comm2.Dispose()
Case ComboBox2.Items.Item(1)
dt.Clear()
Dim comm2 As New SqlCommand
DGV1.DataSource = Nothing
DGV1.Columns.Clear()
comm2.CommandText = Nothing
DGV1.Refresh()
comm2.CommandText = "select l2,sub_code,sub_name,houres from sub_with_sct where sction_ID=1"
comm2.Connection = sqlconn
sqlconn.Open()
dr2 = comm2.ExecuteReader
dt.Load(dr2)
DGV1.AutoGenerateColumns = True
DGV1.DataSource = dt
DGV1.Refresh()
sqlconn.Close()
DGV1.Visible = True
comm2.Dispose()
End Select
End Sub
当我选择第一项时:
当我选择第二项时:
答案 0 :(得分:0)
尝试将rvm rubygems 1.8.7 --force
添加到您的第一个
案件 。在你的所有案件中使用DGV1.Columns.Clear()
代替dt= New DataTable()
。