VB2005的DataGridView查询显示结果问题请教各位高手
VB2005查询显示结果问题请教各位高手:
一个从Access数据库zlb表中查询数据,用DataGridView显示结果,运行时反复选择xh1的值时,DataGridView显示的列顺序每次都是变化的。语句如下:
If xh1 = "01" Then
lbmc = "图纸"
SQLString = "SELECT th As 图号,mc As 名称,xz As 属性,lb As 类别 From zlb WHERE zllb='" & lbmc & "' ORDER BY zllb ASC" (zllb='" & lbmc & Dim UserTable1 As DataTable = DBOperation.DBOperate(SQLString, Msg)
DataGridView1.DataSource = DBOperation.DBOperate(SQLString, Msg)
End If
If xh1 = "02" Then
lbmc = "通知"
SQLString = "SELECT xh As 型号,bj As 部件,wjh As 文件号,rq As 日期 From zlb WHERE zllb='" & lbmc & "' ORDER BY zllb ASC"
Dim UserTable1 As DataTable = DBOperation.DBOperate(SQLString, Msg)
DataGridView1.DataSource = DBOperation.DBOperate(SQLString, Msg)
End If
运行时,第一次选择完xh1后,DataGridView1显示列顺序是:图号、名称、属性、类别。
第二次选择完xh1后,DataGridView1显示列顺序是:部件、型号、日期、文件号。
而不是:型号、部件、文件号、日期。
请教各位高手,哪个地方少什么语句了?请指教。谢谢各位。
[解决办法]
对了,你试着直接解除绑定,不清除行列,试下,我好久没用过datagrieview,不太熟了,
但你这问题,跟绑定了数据源之后,又去绑定新的数据源有关.