[英]VB.Net Filling DataGridview with dataset1 table rows
Noob here, have imported SQL database as datasource into forms app but when I click preview no rows are shown. Noob在这里,已经将SQL数据库作为数据源导入了表单应用程序,但是当我单击“预览”时,没有显示任何行。
Public Class Form1
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the "DataSet1.Ac_Billbook" table. You can move, or remove it, as needed.
'Me.Ac_BillbookTableAdapter.Fill(Me.DataSet1.Ac_Billbook)
For Each table In DataSet1.Tables
ComboBox1.Items.Add(table.ToString)
Next
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
DataGridView1.DataSource = DataSet1.Tables(ComboBox1.SelectedItem)
'DataGridView1.DataBind()
End Sub
End Class
The idea is that I would be able to preview table fields by looking at a table and quickly seeing it. 我的想法是,我可以通过查看表并快速查看它来预览表字段。
You can break down the line where you assigning the table as datasource, so that you can use a breakpoint and use a "dataset visualizer" (small icon with magnifying glass will show it) feature of the VS to check the table content. 您可以分解将表分配为数据源的行,以便可以使用断点并使用VS的“数据集可视化器”(带有放大镜的小图标将显示它)功能来检查表内容。
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim dt as New DataTable
dt = DataSet1.Tables(ComboBox1.SelectedItem).DefaultView
DataGridView1.DataSource = dt
End Sub
Put a Breakpoint on the line with "DataGridView1.DataSource = dt" and have a look, whether the datatable has the desired rows. 将断点放在“ DataGridView1.DataSource = dt”的行上,看看数据表是否具有所需的行。 If no data is there, also test with first table:
如果没有数据,请使用第一个表进行测试:
dt = DataSet1.Tables(0).DefaultView
If there are still no data, then you get nothing from your DB table(s). 如果仍然没有数据,那么您从数据库表中什么也不会得到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.