Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining


Opens an OLE DB table.

[ db_table( 
) ]


A string specifying the name of a database table (such as "Products").
name (optional)
The name of the handle you use to work with the table. You must specify this parameter if you want to return more than one row of results. db_table generates a variable with the specified name that can be used to traverse the rowset or execute multiple action queries.
source_name (optional)
The CSession variable or instance of a class that has the db_source attribute applied to it on which the command executes. See db_source.
hresult (optional)
Identifies the variable that will receive the HRESULT of this database command. If the variable does not exist, it will be automatically injected by the attribute.

Attribute Context

Applies to class, struct
Repeatable No
Required attributes None
Invalid attributes None

For more information about the attribute contexts, see Attribute Contexts.


db_table creates a CTable object, which is used by an OLE DB consumer to open a table. You can use this attribute only at the class level; you cannot use it inline. Use db_column to bind table columns to variables; use db_param to delimit (set the parameter type and so on) of parameters.


The following example opens the Products table for use by CProducts.

[ db_table(L"dbo.Products") ]
class CProducts
   [ db_column(1) ] LONG m_ProductID;

For an example of this attribute used in an application, see the samples AtlAgent and MultiRead.

See Also

OLE DB Consumer Attributes | Attributes Samples

© 2015 Microsoft