I am using ASP.NET 4.5, with <httpRuntime targetFramework="4.5" />
set.
I have an old data helper library method that returns a SQLDatatable using SQLDataAdapter.Fill()
.
I want to add a method to return Task(of SQLDatatable)
- an async equivalent of the old method.
The code I have is like below (only the portion of code that matters is included):
Note:
GetConnectionString()
returns the sql connection stringGetSqlCmd(...)
returns a SQLCommand objectLogError()
logs any exceptionUsing conn As New SqlConnection(GetConnectionString()) Try cmd = GetSqlCmd(strSQL, conn, hash) Await conn.OpenAsync().ConfigureAwait(False) Using datareader = Await cmd.ExecuteReaderAsync().ConfigureAwait(False) userDataTable.Load(datareader) End Using Catch ex As Exception LogError(ex) End Try End Using
And the code works in the ASP.NET application, once I add await to the library method call.
The thing I'm not really sure is if the code above makes sense. Certainly the SQLDataReader is async, but SQLDataTable.Load(datareader) doesn't appear to use ReadAsync (as far as I can tell)...
Does this fact make the above code pointless - meaning, "ExecuteReaderAsync without ReadAsync" is pointless?