Communicating with SQL Server
For an ODBC application to communicate with an instance of Microsoft SQL Server, it must allocate environment and connection handles and connect to the data source. After a connection is established, the application can send queries to the server and process any result sets. When the application has finished using the data source, it disconnects from the data source and frees the connection handle. When the application has freed all its connection handles, it frees the environment handle.
An application can connect to any number of data sources. The application can use a combination of drivers and data sources, the same driver and a combination of data sources, or even the same driver and multiple connections to the same data source.
You can download SQL Native Client ODBC samples from the SQL Server Downloads page on MSDN.
請參閱
概念
SQL Native Client (ODBC)
SQLSetEnvAttr