con = New OleDbConnection(cs)
con.Open()
cmd = New OleDbCommand("Select DISTINCT DesignationDate as [Date], DayNumber as [DN] from employeedesignation where employeeID = '" & EmployeeID3.Text & "' order by DayNumber asc", con)
Dim myDA As OleDbDataAdapter = New OleDbDataAdapter(cmd)
Dim myDataSet As DataSet = New DataSet()
myDA.Fill(myDataSet, "EmployeeDesignation")
dgridempinfo_4.DataSource = myDataSet.Tables("EmployeeDesignation").DefaultView
con.Close()
此代码只填写我的数据网格" dgridempinfo_4",并显示2列,DATE和DN。
我可以通过datagrid属性或代码隐藏列,但是我可以查询DN不会在语句本身中显示吗?
答案 0 :(得分:1)
如果要在查询中包含该列,可能要执行其他数据提取,但又不希望在视图中显示该列,则可以在填充数据集后始终删除要隐藏的列:
table(0).Columns.Remove("Foo")
您也可以指定索引而不是名称,但请确保您的索引正确!:
table(0).Columns.Remove(0)