first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

ADO.NET: CommandType.TableDirect Is Not Supported by SqlCommand.CommandType

CommandType.TableDirect Is Not Supported by SqlCommand.CommandType. The System.Data.OleDb namespace supports it. It follows that the following form works:

string cnnStr = "Provider=SQLOLEDB; Server=(local); Database=pubs; Integrated Security=SSPI;";

using(OleDbConnection cnn = new OleDbConnection(cnnStr))
{
    OleDbCommand cmd = null;
    OleDbDataReader reader = null;
    try
    {
        cnn.Open();
        string tbl = "authors";
        cmd = new OleDbCommand(tbl, cnn);
        cmd.CommandType = CommandType.TableDirect;
        reader = cmd.ExecuteReader();

        //TODO: use reader.
    }
    finally
    {
        if ((reader != null) && (!reader.IsClosed))
        {
            reader.Close();
            reader.Dispose();
        }

        if (cmd != null) cmd.Dispose();
    }
}
mod date: 2006-10-06T22:16:28.000Z