Public Sub BindToControl(ByRef objControl As Object) '--- Declare local variables Dim dadAdapter As SqlDataAdapter Dim dstDataSet As DataSet Dim conDatabase As SqlConnection Dim strConnString As String Dim strSQL As String strConnString = "Server=127.0.0.1;UID=sa;PWD=;Database=Northwind;" strSQL = "SELECT ContactName FROM Customers" '--- Initialize an instance of the connection object conDatabase = New SqlConnection(strConnString) '--- Create an instance of the dataset object dstDataSet = New DataSet() '--- Initialize an instance of the sqldataadapter object dadAdapter = New SqlDataAdapter(strSQL, conDatabase) dadAdapter.Fill(dstDataSet) '--- Connect a datasource to the supplied control objControl.DataSource = dstDataSet '--- Bind data to control objControl.DataBind() '--- Close database connection conDatabase.Close() End SubThis code results in the following error:
objControl.DataBind()Could anyone help me with this problem? All help would be greatly appriciated.