Datagrid仅显示1个结果

时间:2016-12-21 00:18:40

标签: mysql vb.net datagridview

我创建了一个代码来显示来自datagrid的数据,我在数据库上有3个数据,但查询只显示1个结果。这是我的代码:

 Public Sub displayGrid()
    Using connection As New MySqlConnection(connectionstring)
        SQL = "Select * from IPQC_modelParameter"
        Using da As New MySqlDataAdapter(SQL, connection)
            Dim ds = New DataSet
            da.Fill(ds)
            For x As Integer = 0 To ds.Tables(0).Rows.Count
                DataGridView1.Rows.Insert(0) 'this will add a new record on top, always
                DataGridView1.Rows(0).Cells(0).Value = ds.Tables(0).Rows(x)("id")
                DataGridView1.Rows(0).Cells(1).Value = ds.Tables(0).Rows(x)("full_model")
                DataGridView1.Rows(0).Cells(2).Value = ds.Tables(0).Rows(x)("model_name")
                DataGridView1.Rows(0).Cells(3).Value = ds.Tables(0).Rows(x)("parameter")
                DataGridView1.Rows(0).Cells(4).Value = ds.Tables(0).Rows(x)("instrument")
                DataGridView1.Rows(0).Cells(5).Value = ds.Tables(0).Rows(x)("nominal")
                DataGridView1.Rows(0).Cells(6).Value = ds.Tables(0).Rows(x)("tolerance")
                DataGridView1.Rows(0).Cells(7).Value = ds.Tables(0).Rows(x)("ucl")
                DataGridView1.Rows(0).Cells(8).Value = ds.Tables(0).Rows(x)("lcl")
                'DataGridView1.Rows(0).Cells(9).Value = ds.Tables(0).Rows(x)("uot")
                'DataGridView1.Rows(0).Cells(10).Value = ds.Tables(0).Rows(x)("lot")
                DataGridView1.Rows(0).Cells(11).Value = ds.Tables(0).Rows(x)("mrnominal")
                DataGridView1.Rows(0).Cells(12).Value = ds.Tables(0).Rows(x)("mrucl")
                'DataGridView1.Rows(0).Cells(13).Value = ds.Tables(0).Rows(x)("status")
                'DataGridView1.Rows(0).Cells(14).Value = ds.Tables(0).Rows(x)("mp_id")
                DataGridView1.Rows(0).Cells(15).Value = ds.Tables(0).Rows(x)("usl")
                DataGridView1.Rows(0).Cells(16).Value = ds.Tables(0).Rows(x)("lsl")
                DataGridView1.Rows(0).Cells(17).Value = ds.Tables(0).Rows(x)("conversion")

            Next

        End Using
    End Using
End Sub

0 个答案:

没有答案