' SQL Server からのデータで WinDataSource を埋めるメソッド。このメソッドを ' 拡張して、キー、検索条件、並べ替え順序などを引数にとるオーバーロードを作成できます。 Public Sub FillData() Dim cn As New SqlConnection(_cn) Dim cm As SqlCommand = cn.CreateCommand() cm.CommandText = "SELECT CategoryID,CategoryName,Description," + _ "Picture FROM Categories ORDER BY CategoryName ASC" cm.CommandType = CommandType.Text cn.Open() Dim dr As SqlDataReader = cm.ExecuteReader(CommandBehavior.Default) Dim rowCount As Integer While dr.Read = True rowCount += 1 MyBase.Rows.Add(New Object() {dr("CategoryID"), _ dr("CategoryName"), _ dr("Description"), _ dr("Picture")}) End While MyBase.Rows.SetCount(rowCount) dr.Close() cn.Dispose() End Sub