Imports System.Data.SqlClient
Public Class Form3
Dim conn As New SqlConnection
Dim ds As New DataSet
Public flag As Integer
Function open() As Long
ds.Tables.Clear()
Dim str = "select * from 采购单"
Dim da As New SqlDataAdapter(str, conn)
da.Fill(ds)
DataGridView1.ColumnCount = ds.Tables(0).Columns.Count
DataGridView1.RowCount = ds.Tables(0).Rows.Count
For i = 0 To ds.Tables(0).Rows.Count - 1
For j = 0 To ds.Tables(0).Columns.Count - 1
DataGridView1.Rows(i).Cells(j).Value = ds.Tables(0).Rows(i).ItemArray(j)
Next
Next
For i = 0 To ds.Tables(0).Columns.Count - 1
DataGridView1.Columns(i).HeaderText = ds.Tables(0).Columns(i).ColumnName
这个看有什么需求了。