>Dim oCommand As IDbCommand = Nothing >Dim oConnection As IDbConnection = Nothing >Dim oDataAdapter As IDbDataAdapter = Nothing >Dim oDataSet As DataSet >Dim oDataView As DataView >oConnection = New OleDbConnection(oApp.aConnection(1)) >oDataAdapter = New OleDbDataAdapter >oCommand = New OleDbCommand >oCommand.Connection = oConnection >oCommand.CommandText = "RAND(-1)" >oCommand.Connection.Open() >oCommand.ExecuteNonQuery() >oCommand.Connection.Close()Don't close the connection here. Let the dataadapter use the same connection (and thus same environment)
>oCommand.CommandText = "SELECT TOP 10 RAND() AS Test,Video.Date,..." >oDataAdapter.SelectCommand = oCommand >oDataSet = New DataSet >oDataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey >oDataAdapter.Fill(oDataSet) >oDataSet.Tables("Table").TableName = "Temp" >oDataView = New DataView >oDataView = oDataSet.Tables("Temp").DefaultView >loRow = oDataView(0).Row >Since the connection is open when the .Fill is called the dataadapter will leave the connection open and you will need to close it yourself afterwards