Fill: SelectCommand.Connection property has not been initialized.
Når jeg kalder Sub'en BindGrid() får jeg følgende fejl:Fill: SelectCommand.Connection property has not been initialized.
Hvad er der galt?
--- kildekoden ---
Imports System.Data
Imports System.Data.SqlClient
Public Class customer
Inherits System.Web.UI.Page
Sub BindGrid()
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter = New SqlDataAdapter("select * from Customers", MyConnection)
Dim DS As DataSet = New DataSet
MyCommand.Fill(DS, "Customers")
MyDataGrid.DataSource = DS.Tables("Customers").DefaultView
MyDataGrid.DataBind()
End Sub
