OLE DB How-to Topics Results + Filestream + Bulk Copy Data Using IRowsetFastLoad (OLE DB) Change a SQL Server Authentication User Password (OLE DB)

Size: px
Start display at page:

Download "OLE DB How-to Topics Results + Filestream + Bulk Copy Data Using IRowsetFastLoad (OLE DB) Change a SQL Server Authentication User Password (OLE DB)"

Transcription

1 Table of Contents OLE DB How-to Topics Results + Filestream + Bulk Copy Data Using IRowsetFastLoad (OLE DB) Change a SQL Server Authentication User Password (OLE DB) Display Column and Catalog Metadata for Sparse Columns (OLE DB) Enumerate OLE DB Data Sources (OLE DB) Fetch Columns Using IRow::GetColumns (OLE DB) Fetch Columns Using IRow::GetColumns (or IRow::Open) and ISequentialStream Integrated Kerberos Authentication (OLE DB) Obtain a FAST_FORWARD Cursor Retrieve Rows Using Bookmarks (OLE DB) Send BLOB Data to SQL SERVER Using IROWSETFASTLOAD and ISEQUENTIALSTREAM (OLE DB) Set Large Data (OLE DB) Use Enhanced Date and Time Features (OLE DB) Use Large CLR UDTs (OLE DB) Use Table-Valued Parameters (OLE DB)

2 OLE DB How-to Topics 1/24/ min to read Edit Online THIS TOPIC APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data Warehouse To use the SQL Server Native Client OLE DB provider, you have to understand how to make a connection to the server, execute the command, and process the results. In This Section Processing Results How-to Topics (OLE DB) Set Large Data (OLE DB) Enumerate OLE DB Data Sources (OLE DB) Bulk Copy Data Using IRowsetFastLoad (OLE DB) Obtain a FAST_FORWARD Cursor Retrieve Rows Using Bookmarks (OLE DB) Fetch Columns Using IRow::GetColumns (or IRow::Open) and ISequentialStream Fetch Columns Using IRow::GetColumns (OLE DB) Change a SQL Server Authentication User Password (OLE DB) Use Enhanced Date and Time Features (OLE DB) Filestream and OLE DB Send BLOB Data to SQL SERVER Using IROWSETFASTLOAD and ISEQUENTIALSTREAM (OLE DB) Use Large CLR UDTs (OLE DB) Display Column and Catalog Metadata for Sparse Columns (OLE DB) Integrated Kerberos Authentication (OLE DB) Use Table-Valued Parameters (OLE DB) See Also SQL Server Native Client Programming

3 Processing Results How-to Topics (OLE DB) 1/24/ min to read Edit Online THIS TOPIC APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data Warehouse Processing results in an OLE DB application involves first determining the characteristics of the result set, and then retrieving the data into program variables. If the command executes a stored procedure, you also must know how to process return codes and output parameters from the stored procedures. In This Section Execute a Stored Procedure (Using ODBC CALL Syntax) and Process Return Codes and Output Parameters (OLE DB) Execute a Stored Procedure (Using RPC Syntax) and Process Return Codes and Output Parameters (OLE DB) Execute a User-Defined Function and Process Return Code (OLE DB) Fetch Rows from a Result Set (OLE DB) See Also OLE DB How-to Topics

4 Filestream and OLE DB 1/24/ min to read Edit Online THIS TOPIC APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data Warehouse This section contains four samples that show how to use SQL Server Native Client OLE DB with the filestream feature: Read a FILESTREAM Column to File Using IBCPSession (OLE DB) Retrieve Data from a FILESTREAM Column Using ISequentialStream (OLE DB) Send Data to a FILESTREAM Column Using ISequentialStream Bound to ICommandText Parameter (OLE DB) Send Data to a FILESTREAM Column Using IRowsetFastUpload (OLE DB)

5 Bulk Copy Data Using IRowsetFastLoad (OLE DB) 1/24/ min to read Edit Online THIS TOPIC APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data Warehouse This sample shows the use of IRowsetFastLoad for bulk copying of records into a table. The consumer notifies SQLOLEDB of its need for bulk copying by setting the SQLOLEDB provider-specific property SSPROP_ENABLEFASTLOAD to VARIANT_TRUE. With the property set on the data source, the consumer creates a SQLOLEDB session. The new session allows the consumer access to IRowsetFastLoad. A complete sample is available that illustrates the use of IRowsetFastLoad for bulk copying of the records into a table. In this sample, 10 records are added to the table IRFLTable. You need to create the table IRFLTable in the database. This sample requires the AdventureWorks sample database, which you can download from the Microsoft SQL Server Samples and Community Projects home page. IMPORTANT When possible, use Windows Authentication. If Windows Authentication is not available, prompt users to enter their credentials at run time. Avoid storing credentials in a file. If you must persist credentials, you should encrypt them with the Win32 crypto API. To bulk copy data into a SQL Server table 1. Establish a connection to the data source. 2. Set the SQLOLEDB provider-specific data source property SSPROP_ENABLEFASTLOAD to VARIANT_TRUE. With this property set to VARIANT_TRUE, the newly created session allows the consumer access to IRowsetFastLoad. 3. Create a session requesting the IOpenRowset interface. 4. Call IOpenRowset::OpenRowset to open a rowset that includes all the rows from the table (in which data is to be copied using bulk-copy operation). 5. Do the necessary bindings and create an accessor using IAccessor::CreateAccessor. 6. Set up the memory buffer from which the data will be copied to the table. 7. Call IRowsetFastLoad::InsertRow to bulk copy the data in to the table. Example In this example, 10 records are added to the table IRFLTable. You need to create the table IRFLTable in the database. This sample is not supported on IA64. Execute the first ( Transact-SQL) code listing to create the table used by the application. Compile with ole32.lib oleaut32.lib and execute the following C++ code listing. This application connects to your computer's default SQL Server instance. On some Windows operating systems, you will need to change (localhost) or (local) to the name of your SQL Server instance. To connect to a named instance, change the connection string from L"(local)" to L"(local)\\name", where name is the named instance. By default, SQL Server Express installs to a

6 named instance. Make sure your INCLUDE environment variable includes the directory that contains sqlncli.h. Execute the third ( Transact-SQL) code listing to delete the table used by the application. USE AdventureWorks GO IF EXISTS (SELECT name FROM sysobjects WHERE name = 'IRFLTable') DROP TABLE IRFLTable GO CREATE TABLE IRFLTable (col_vchar varchar(30)) // compile with: ole32.lib oleaut32.lib #define DBINITCONSTANTS #define OLEDBVER 0x0250 // to include correct interfaces #include <oledb.h> #include <oledberr.h> #include <stdio.h> #include <stddef.h> #include <sqlncli.h> // for offsetof UWORD 2 byte unsigned integer. typedef unsigned short UWORD; SDWORD 4 byte signed integer. typedef signed long SDWORD; WCHAR g_wsztable[] = L"IRFLTable"; WCHAR g_strtestloc[100] = L"localhost"; WCHAR g_strtestdbname[] = L"AdventureWorks"; const UWORD g_coption = 4; const UWORD MAXPROPERTIES = 5; const ULONG DEFAULT_CBMAXLENGTH = 20; IMalloc* g_pimalloc = NULL; IDBInitialize* g_pidbinitialize = NULL; // Given an ICommand pointer, properties, and query, a rowsetpointer is returned. HRESULT CreateSessionCommand( DBPROPSET* rgpropertysets, ULONG ulcpropcount, CLSID clsidprov ); // Use to set properties and execute a given query. HRESULT ExecuteQuery ( IDBCreateCommand* pidbcreatecommand, WCHAR* pwszquery, DBPROPSET* rgpropertysets, ULONG ulcpropcount, LONG* pcrowsaffected, IRowset** ppirowset, BOOL fsuccessonly = TRUE ); // Use to set up options for call to IDBInitialize::Initialize. void SetupOption ( DBPROPID PropID, WCHAR *wszval, DBPROP * pdbprop ); // Sets fastload property on/off for session. HRESULT SetFastLoadProperty(BOOL fset); // IRowsetFastLoad inserting data. HRESULT FastLoadData(); // How to lay out each column in memory. struct COLUMNDATA { DBLENGTH dwlength; // Length of data (not space allocated). DWORD dwstatus; // Status of column. BYTE bdata[1]; // Store data here as a variant. ;

7 #define COLUMN_ALIGNVAL 8 #define ROUND_UP(Size, Amount)(((DWORD)(Size) + ((Amount)-1)) & ~((Amount)-1)) int main() { HRESULT hr = NOERROR; HRESULT hr2 = NOERROR; // OLE initialized? BOOL finitialized = FALSE; // One property set for initializing. DBPROPSET rgpropertysets[1]; // Properties within above property set. DBPROP rgdbproperties[g_coption]; IDBCreateCommand* pidbcreatecommand = NULL; IRowset* pirowset = NULL; DBPROPSET* rgproperties = NULL; IAccessor* piaccessor = NULL; // Basic initialization. if ( FAILED(CoInitialize(NULL)) ) goto cleanup; else finitialized = TRUE; hr = CoGetMalloc(MEMCTX_TASK, &g_pimalloc); if ((!g_pimalloc) FAILED(hr)) goto cleanup; // Set up property set for call to IDBInitialize in CreateSessionCommand. rgpropertysets[0].rgproperties = rgdbproperties; rgpropertysets[0].cproperties = g_coption; rgpropertysets[0].guidpropertyset = DBPROPSET_DBINIT; SetupOption(DBPROP_INIT_CATALOG, g_strtestdbname, &rgdbproperties[0]); SetupOption(DBPROP_AUTH_INTEGRATED, L"SSPI", &rgdbproperties[1]); SetupOption(DBPROP_INIT_DATASOURCE, g_strtestloc, &rgdbproperties[3]); if (!SUCCEEDED( hr = CreateSessionCommand(rgPropertySets, 1, CLSID_SQLNCLI11))) goto cleanup; // Get IRowsetFastLoad and insert data into IRFLTable. if (FAILED(hr = FastLoadData())) goto cleanup; cleanup: // Release memory. if (rgproperties && rgproperties->rgproperties) delete [](rgproperties->rgproperties); if (rgproperties) delete []rgproperties; if (pidbcreatecommand) pidbcreatecommand->release(); if (piaccessor) piaccessor->release(); if (pirowset) pirowset->release(); if (g_pimalloc) g_pimalloc->release(); if (g_pidbinitialize) { hr2 = g_pidbinitialize->uninitialize();

8 if (FAILED(hr2)) printf("uninitialize failed\n"); if (finitialized) CoUninitialize(); if (SUCCEEDED(hr)) printf("test completed successfully.\n\n"); else printf("test failed.\n\n"); HRESULT FastLoadData() { HRESULT hr = E_FAIL; HRESULT hr2 = E_FAIL; DBID TableID; IDBCreateSession* pidbcreatesession = NULL; IOpenRowset* piopenrowsetfl = NULL; IRowsetFastLoad* pifastload = NULL; IAccessor* piaccessor = NULL; HACCESSOR haccessor = 0; DBBINDSTATUS onestatus = 0; DBBINDING onebinding; ULONG uloffset = 0; TableID.uName.pwszName = NULL; LONG i = 0; void* pdata = NULL; COLUMNDATA* pcoldata = NULL; TableID.eKind = DBKIND_NAME; // if (!(TableID.uName.pwszName = new WCHAR[wcslen(g_wszTable) + 2]) ) LPOLESTR x = TableID.uName.pwszName = new WCHAR[wcslen(g_wszTable) + 2]; if (!x) return E_FAIL; wcsncpy_s(tableid.uname.pwszname, wcslen(g_wsztable) + 2, g_wsztable, wcslen(g_wsztable)+1); TableID.uName.pwszName[wcslen(g_wszTable)+1] = (WCHAR) NULL; // Get the fastload pointer. if (FAILED(hr = SetFastLoadProperty(TRUE))) goto cleanup; if ( FAILED( hr = g_pidbinitialize->queryinterface( IID_IDBCreateSession, (void **) &pidbcreatesession ))) goto cleanup; if ( FAILED( hr = pidbcreatesession->createsession( NULL, IID_IOpenRowset, (IUnknown **) &piopenrowsetfl ))) goto cleanup; // Get IRowsetFastLoad initialized to use the test table. if (FAILED(hr = piopenrowsetfl->openrowset(null, &TableID, NULL, IID_IRowsetFastLoad, 0, NULL, (LPUNKNOWN *)&pifastload))) goto cleanup; // Set up custom bindings. onebinding.dwpart = DBPART_VALUE DBPART_LENGTH DBPART_STATUS; onebinding.iordinal = 1; onebinding.ptypeinfo = NULL; onebinding.obvalue = uloffset + offsetof(columndata,bdata);

9 onebinding.obvalue = uloffset + offsetof(columndata,bdata); onebinding.oblength = uloffset + offsetof(columndata,dwlength); onebinding.obstatus = uloffset + offsetof(columndata,dwstatus); onebinding.cbmaxlen = 30; // Size of varchar column. onebinding.ptypeinfo = NULL; onebinding.pobject = NULL; onebinding.pbindext = NULL; onebinding.dwflags = 0; onebinding.eparamio = DBPARAMIO_NOTPARAM; onebinding.dwmemowner = DBMEMOWNER_CLIENTOWNED; onebinding.bprecision= 0; onebinding.bscale = 0; onebinding.wtype = DBTYPE_STR; uloffset = onebinding.cbmaxlen + offsetof(columndata, bdata); uloffset = ROUND_UP( uloffset, COLUMN_ALIGNVAL ); if ( FAILED( hr = pifastload->queryinterface(iid_iaccessor, (void **) &piaccessor))) return hr; if (FAILED(hr = piaccessor->createaccessor( DBACCESSOR_ROWDATA, 1, &onebinding, uloffset, &haccessor, &onestatus))) return hr; // Set up memory buffer. pdata = new BYTE[40]; if (!(pdata /* = new BYTE[40]*/ )) { hr = E_FAIL; goto cleanup; pcoldata = (COLUMNDATA*)pData; pcoldata->dwlength = (SDWORD)strlen("Show the data") + 1; pcoldata->dwstatus = 0; memcpy(&(pcoldata->bdata), "Show the data", strlen("show the data") + 1); for ( i = 0 ; i < 10 ; i++ ) if (FAILED(hr = pifastload->insertrow(haccessor, pdata))) goto cleanup; if (FAILED(hr = pifastload->commit(true))) printf("error on IRFL::Commit\n"); cleanup: if (FAILED(hr2 = SetFastLoadProperty(FALSE))) printf("setfastloadproperty(false) failed with %x", hr2); if (piaccessor && haccessor) if (FAILED(pIAccessor->ReleaseAccessor(hAccessor, NULL))) hr = E_FAIL; if (piaccessor) piaccessor->release(); if (pifastload) pifastload->release(); if (piopenrowsetfl) piopenrowsetfl->release(); if (pidbcreatesession) pidbcreatesession->release(); if (TableID.uName.pwszName) delete []TableID.uName.pwszName;

10 return hr; HRESULT SetFastLoadProperty(BOOL fset) { HRESULT hr = S_OK; IDBProperties* pidbprops = NULL; DBPROP rgprops[1]; DBPROPSET PropSet; VariantInit(&rgProps[0].vValue); rgprops[0].dwoptions = DBPROPOPTIONS_REQUIRED; rgprops[0].colid = DB_NULLID; rgprops[0].vvalue.vt = VT_BOOL; rgprops[0].dwpropertyid = SSPROP_ENABLEFASTLOAD; if (fset == TRUE) rgprops[0].vvalue.boolval = VARIANT_TRUE; else rgprops[0].vvalue.boolval = VARIANT_FALSE; PropSet.rgProperties = rgprops; PropSet.cProperties = 1; PropSet.guidPropertySet = DBPROPSET_SQLSERVERDATASOURCE; if (SUCCEEDED(hr = g_pidbinitialize->queryinterface(iid_idbproperties, (LPVOID *)&pidbprops))) hr = pidbprops->setproperties(1, &PropSet); VariantClear(&rgProps[0].vValue); if (pidbprops) pidbprops->release(); return hr; HRESULT CreateSessionCommand( DBPROPSET* [in] property sets ULONG ulcpropcount, [in] count of prop sets. CLSID clsidprov) { [in] Provider CLSID. HRESULT hr = NOERROR; IDBCreateSession* pidbcreatesession = NULL; IDBProperties* pidbproperties = NULL; UWORD i = 0, j = 0; // indexes. if (ulcpropcount &&!rgpropertysets) { hr = E_INVALIDARG; return hr; if (!SUCCEEDED(hr = CoCreateInstance(clsidProv, NULL,CLSCTX_INPROC_SERVER, IID_IDBInitialize, (void **)&g_pidbinitialize))) goto CLEANUP; if (!SUCCEEDED(hr = g_pidbinitialize->queryinterface( IID_IDBProperties, (void **)&pidbproperties))) goto CLEANUP; if (!SUCCEEDED(hr = pidbproperties->setproperties(ulcpropcount, rgpropertysets))) goto CLEANUP; if (!SUCCEEDED(hr = g_pidbinitialize->initialize())) { printf("call to initialize failed.\n"); goto CLEANUP; CLEANUP:

11 CLEANUP: if (pidbproperties) pidbproperties->release(); if (pidbcreatesession) pidbcreatesession->release(); for (i = 0 ; i < ulcpropcount ; i++) for (j = 0 ; j < rgpropertysets[i].cproperties ; j++) VariantClear(&(rgPropertySets[i].rgProperties[j]).vValue); return hr; void SetupOption (DBPROPID PropID, WCHAR *wszval, DBPROP * pdbprop ) { pdbprop->dwpropertyid = PropID; pdbprop->dwoptions = DBPROPOPTIONS_REQUIRED; pdbprop->colid = DB_NULLID; pdbprop->vvalue.vt = VT_BSTR; pdbprop->vvalue.bstrval = SysAllocStringLen(wszVal, wcslen(wszval)); USE AdventureWorks GO IF EXISTS (SELECT name FROM sysobjects WHERE name = 'IRFLTable') DROP TABLE IRFLTable GO

12 Change a SQL Server Authentication User Password (OLE DB) 1/24/ min to read Edit Online THIS TOPIC APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data Warehouse This sample shows how to use OLE DB to change the password of a user account under SQL Server Authentication. IMPORTANT When possible, use Windows Authentication. If Windows Authentication is not available, prompt users to enter their credentials at run time. Avoid storing credentials in a file. If you must persist credentials, you should encrypt them with the Win32 crypto API. Example Before building, update the.c++ code to specify the user ID, old password, and new password. This application connects to your computer's default SQL Server instance. On some Windows operating systems, you will need to change (localhost) or (local) to the name of your SQL Server instance. To connect to a named instance, change the connection string from L"(local)" to L"(local)\\name", where name is the named instance. By default, SQL Server Express installs to a named instance. Make sure your INCLUDE environment variable includes the directory that contains sqlncli.h. Compile with ole32.lib oleaut32.lib. To build this sample, you will need a SQL Server Authentication user account for which you know the password. To allow logins under SQL Server Authentication, open SQL Server Management Studio, right click on the Server node in Object Explorer, and select Properties. Select Security and enable SQL Server and Windows Authentication mode. To add a user account under SQL Server Authentication, right click the Security node in Object Explorer and select Add. The server on which you will run this sample must have at least one login enabled for SQL Server Authentication. The server must also be enabled to allow SQL Server Authentication logins. // compile with: ole32.lib oleaut32.lib void InitializeAndEstablishConnection(); #define STATUSDUMP(status) case status : wprintf(l"status"); break; #define UNICODE #define DBINITCONSTANTS #define INITGUID #include <assert.h> #include <windows.h> #include <stdio.h> #include <stddef.h> #include <IOSTREAM> #include <cguid.h> #include <oledb.h> #include <oledberr.h> #include <SQLNCLI.h>

13 #include <SQLNCLI.h> LPMALLOC pmalloc = NULL; IDBInitialize * pidbinitialize = NULL; HRESULT hr; void DumpErrorInfo (IUnknown* pobjectwitherror, REFIID IID_InterfaceWithError); void DumpErrorInfo (IUnknown* pobjectwitherror, REFIID IID_InterfaceWithError, BOOL &has_sql_errors); int main() { // All the initialization activities in a separate function. InitializeAndEstablishConnection(); if ( FAILED( pidbinitialize->uninitialize() ) ) // Uninitialize is not required, but fails if an interface was not released. printf("problem uninitializing.\n"); pidbinitialize->release(); CoUninitialize(); ; void InitializeAndEstablishConnection() { IDBProperties * pidbproperties = NULL; const ULONG ninitprops = 4; DBPROP InitProperties[nInitProps]; const ULONG nssinitprops = 1; DBPROP SSInitProperties[nSSInitProps]; const ULONG npropset = 2; DBPROPSET rginitpropset[npropset]; // Initialize the COM library. CoInitialize(NULL); CoGetMalloc(1, &pmalloc); CLSID clsid; CLSIDFromProgID(L"SQLNCLI11", &clsid); // Obtain access to the SQLOLEDB provider. hr = CoCreateInstance( clsid, NULL, CLSCTX_INPROC_SERVER, IID_IDBInitialize, (void **) &pidbinitialize); if (FAILED(hr)) printf("failed in CoCreateInstance().\n"); // Initialize the property values needed to establish the connection. for (int i = 0; i < ninitprops; i++) VariantInit(&InitProperties[i].vValue); // Specify database name. InitProperties[0].dwPropertyID = DBPROP_INIT_CATALOG; InitProperties[0].vValue.vt = VT_BSTR; // Change the following line to use any database on your server InitProperties[0].vValue.bstrVal = SysAllocString(L"master"); InitProperties[0].dwOptions = DBPROPOPTIONS_REQUIRED; InitProperties[0].colid = DB_NULLID; InitProperties[1].dwPropertyID = DBPROP_AUTH_USERID; InitProperties[1].vValue.vt = VT_BSTR; // Modify the following line to add the user ID of a SQL Server Authentication account on your server InitProperties[1].vValue.bstrVal = SysAllocString(L""); InitProperties[1].dwOptions = DBPROPOPTIONS_REQUIRED; InitProperties[1].colid = DB_NULLID; InitProperties[2].dwPropertyID = DBPROP_AUTH_PASSWORD; InitProperties[2].vValue.vt = VT_BSTR; // Modify the following line to add the new SQL Server Authentication password InitProperties[2].vValue.bstrVal = SysAllocString(L""); InitProperties[2].dwOptions = DBPROPOPTIONS_REQUIRED; InitProperties[2].colid = DB_NULLID; InitProperties[3].dwPropertyID = DBPROP_INIT_DATASOURCE;

14 InitProperties[3].dwPropertyID = DBPROP_INIT_DATASOURCE; InitProperties[3].vValue.vt = VT_BSTR; InitProperties[3].vValue.bstrVal = SysAllocString(L"(local)"); InitProperties[3].dwOptions = DBPROPOPTIONS_REQUIRED; InitProperties[3].colid = DB_NULLID; SSInitProperties[0].dwPropertyID = SSPROP_AUTH_OLD_PASSWORD; SSInitProperties[0].vValue.vt = VT_BSTR; // Modify the following line to specify the existing SQL Server Authentication password SSInitProperties[0].vValue.bstrVal = SysAllocString(L""); SSInitProperties[0].dwOptions = DBPROPOPTIONS_REQUIRED; SSInitProperties[0].colid = DB_NULLID; rginitpropset[0].guidpropertyset = DBPROPSET_DBINIT; rginitpropset[0].cproperties = ninitprops; rginitpropset[0].rgproperties = InitProperties; rginitpropset[1].guidpropertyset = DBPROPSET_SQLSERVERDBINIT; rginitpropset[1].cproperties = nssinitprops; rginitpropset[1].rgproperties = SSInitProperties; // Set initialization properties. hr = pidbinitialize->queryinterface( IID_IDBProperties, (void **)&pidbproperties); if (FAILED(hr)) printf("failed to obtain IDBProperties interface.\n"); hr = pidbproperties->setproperties( npropset, rginitpropset); if (FAILED(hr)) printf("failed to set initialization properties.\n"); pidbproperties->release(); // establish connection to the data source. DWORD now = GetTickCount(); if ( FAILED(pIDBInitialize->Initialize()) ) { printf("problem in initializing.\n"); DumpErrorInfo(pIDBInitialize, IID_IDBInitialize); DWORD tookms = GetTickCount() - now; printf("connection took %d ms.\n", tookms); // DumpErrorInfo queries SQLOLEDB error interfaces, retrieving available status // or error information. This version is called when SQL Server errors are not expected. void DumpErrorInfo (IUnknown* pobjectwitherror, REFIID IID_InterfaceWithError) { BOOL has_sql_errors; DumpErrorInfo (pobjectwitherror, IID_InterfaceWithError, has_sql_errors); // DumpErrorInfo queries SQLOLEDB error interfaces, retrieving available status // or error information. This version is called when an SQL Server error could occur. void DumpErrorInfo (IUnknown* pobjectwitherror, REFIID IID_InterfaceWithError, BOOL &has_sql_errors ) { // Interfaces used in the example. IErrorInfo * pierrorinfoall = NULL; IErrorInfo * pierrorinforecord = NULL; IErrorRecords * pierrorrecords = NULL; ISupportErrorInfo * pisupporterrorinfo = NULL; ISQLErrorInfo * pisqlerrorinfo = NULL; ISQLServerErrorInfo * pisqlservererrorinfo = NULL; // Number of error records. ULONG nrecs; ULONG nrec; // Basic error information from GetBasicErrorInfo. ERRORINFO errorinfo;

15 ERRORINFO errorinfo; // IErrorInfo values. BSTR bstrdescription; BSTR bstrsource; // ISQLErrorInfo parameters. BSTR bstrsqlstate; LONG lnativeerror; // ISQLServerErrorInfo parameter pointers. SSERRORINFO * psserrorinfo = NULL; OLECHAR * psserrorstrings = NULL; // Hard-code an American English locale for the example. DWORD MYLOCALEID = 0x0409; has_sql_errors = 0; // Only ask for error information if the interface supports it. if (FAILED(pObjectWithError->QueryInterface(IID_ISupportErrorInfo, (void**) &pisupporterrorinfo))) wprintf(l"supporterrorerrorinfo interface not supported\n"); else if (FAILED(pISupportErrorInfo->InterfaceSupportsErrorInfo(IID_InterfaceWithError))) wprintf(l"interfacewitherror interface not supported\n"); // Do not test the return of GetErrorInfo. It can succeed and return // a NULL pointer in pierrorinfoall. Simply test the pointer. GetErrorInfo(0, &pierrorinfoall); // Test to see if it's a valid OLE DB IErrorInfo interface exposing a list of records. if (pierrorinfoall!= NULL) { if (SUCCEEDED(pIErrorInfoAll->QueryInterface(IID_IErrorRecords, (void**) &pierrorrecords))) { pierrorrecords->getrecordcount(&nrecs); // Within each record, retrieve information from each of the defined interfaces. for (nrec = 0; nrec < nrecs; nrec++) { ULONG errorno = nrecs - nrec - 1; // From IErrorRecords, get the HRESULT and a reference to the ISQLErrorInfo interface. pierrorrecords->getbasicerrorinfo(errorno, &errorinfo); pierrorrecords->getcustomerrorobject(errorno,iid_isqlerrorinfo, (IUnknown**) &pisqlerrorinfo); // Display the HRESULT, then use the ISQLErrorInfo. wprintf(l"hresult:\t%#x\n", errorinfo.hrerror); if (pisqlerrorinfo!= NULL) { pisqlerrorinfo->getsqlinfo(&bstrsqlstate, &lnativeerror); // Display SQLSTATE and native error values. wprintf(l"sqlstate:\t%s\nnative Error:\t%ld\n", bstrsqlstate, lnativeerror); // SysFree BSTR references. SysFreeString(bstrSQLSTATE); // Get the ISQLServerErrorInfo interface from // ISQLErrorInfo before releasing the reference. pisqlerrorinfo->queryinterface(iid_isqlservererrorinfo, (void**) &pisqlservererrorinfo); pisqlerrorinfo->release(); // Test to ensure the reference is valid, then get error information from ISQLServerErrorInfo. if (pisqlservererrorinfo!= NULL) { pisqlservererrorinfo->geterrorinfo(&psserrorinfo, &psserrorstrings); // ISQLServerErrorInfo::GetErrorInfo succeeds even when it // has nothing to return. Test the pointers before using. if (psserrorinfo) { // Display the state and severity from the returned // information. The error message comes from // IErrorInfo::GetDescription.

16 >wlinenumber); wprintf(l"error state:\t%d\nseverity:\t%d\n", psserrorinfo->bstate, psserrorinfo->bclass); wprintf(l"procedure:\t%s\nline:\t%d\n", psserrorinfo->pwszprocedure, psserrorinfo- has_sql_errors++; // IMalloc::Free needed to release references on returned values. pmalloc->free(psserrorstrings); pmalloc->free(psserrorinfo); pisqlservererrorinfo->release(); if (SUCCEEDED(pIErrorRecords->GetErrorInfo(errno, MYLOCALEID, &pierrorinforecord))) { // Get the source and description (error message) from the record's IErrorInfo. pierrorinforecord->getsource(&bstrsource); pierrorinforecord->getdescription(&bstrdescription); if (bstrsource!= NULL) { wprintf(l"source:\t\t%s\n", bstrsource); SysFreeString(bstrSource); if (bstrdescription!= NULL) { wprintf(l"error message:\t%s\n", bstrdescription); SysFreeString(bstrDescription); pierrorinforecord->release(); pierrorrecords->release(); else { // IErrorInfo is valid; get the source and // description to see what it is. pierrorinfoall->getsource(&bstrsource); pierrorinfoall->getdescription(&bstrdescription); if (bstrsource!= NULL) { wprintf(l"source:\t\t%s\n", bstrsource); SysFreeString(bstrSource); if (bstrdescription!= NULL) { wprintf(l"error message:\t%s\n", bstrdescription); SysFreeString(bstrDescription); pierrorinfoall->release(); else wprintf(l"geterrorinfo failed.\n"); if (pisupporterrorinfo!= NULL) pisupporterrorinfo->release();

17 Display Column and Catalog Metadata for Sparse Columns (OLE DB) 1/24/ min to read Edit Online THIS TOPIC APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data Warehouse This sample creates a table with three columns: a sparse column, a column that is not a sparse column, and a columnset column. The sample then displays OLE DB flags showing the column and catalog metadata for the nonsparse column and the columnset column. This sample works with SQL Server 2008 or later. For more information about sparse columns, see Sparse Columns Support in SQL Server Native Client. Example Make sure your INCLUDE environment variable includes the directory that contains sqlncli.h. #include <stddef.h> #include <comdef.h> #include <msdasc.h> #include <sqlncli.h> #define CHECKED(_hr) \ do { \ if (FAILED(hr =_hr)) { \ PrintHR(hr); \ goto ERR; \ \ while (0) #define CHECK_NOT_NULL(x) \ do { \ if((x) == NULL) { \ PrintHR(E_OUTOFMEMORY); \ goto ERR; \ \ while(0) #define SAFE_RELEASE(pI) \ do { \ if (pi) { \ pi->release(); \ pi = 0; \ \ while(0) #define PROVIDER_FREE(pv) \ do { \ if (pv) { \ CoTaskMemFree(pv); \ pv = NULL; \ \ while(0) #define PRINT_FLAGS(f,m) \ do { \ if ((f & m) == m) \ wprintf(l"%ls, ", L#m); \

18 while(0) #define PrintHR(hr) PrintHR_internal(hr, FILE, LINE ) #define CHECKED3(_hr,_Obj,_IID) \ do { \ if (FAILED(hr = _hr)) { \ DumpErrorInfo(_Obj,_IID); \ goto ERR; \ \ while(0) void PrintHR_internal(HRESULT hr, char * szfile, ULONG uline) { wprintf(l"error HR = %d (%x) %hs(%d)\n", hr, hr, szfile, uline); // DumpErrorInfo queries error interfaces, retrieving available status or error information. void DumpErrorInfo ( IUnknown* pobjectwitherror, REFIID IID_InterfaceWithError ) { // Interfaces used in the example. IErrorInfo * pierrorinfoall = NULL; IErrorInfo * pierrorinforecord = NULL; IErrorRecords * pierrorrecords = NULL; ISupportErrorInfo * pisupporterrorinfo = NULL; ISQLErrorInfo * pisqlerrorinfo = NULL; ISQLServerErrorInfo * pisqlservererrorinfo = NULL; // Number of error records. ULONG nrecs; ULONG nrec; // Basic error information from GetBasicErrorInfo. ERRORINFO errorinfo; // IErrorInfo values. BSTR bstrdescription; BSTR bstrsource; // ISQLErrorInfo parameters. BSTR bstrsqlstate; LONG lnativeerror; // ISQLServerErrorInfo parameter pointers. SSERRORINFO * psserrorinfo = NULL; OLECHAR * psserrorstrings = NULL; // Hard-code an American English locale for the example. DWORD MYLOCALEID = 0x0409; // Only ask for error information if the interface supports it. if (FAILED(pObjectWithError->QueryInterface(IID_ISupportErrorInfo, (void**) &pisupporterrorinfo))) { wprintf(l"supporterrorerrorinfo interface not supported\n"); return; if (FAILED(pISupportErrorInfo->InterfaceSupportsErrorInfo(IID_InterfaceWithError))) { wprintf(l"interfacewitherror interface not supported\n"); return; // Do not test the return of GetErrorInfo. It can succeed and return // a NULL pointer in pierrorinfoall. Simply test the pointer. GetErrorInfo(0, &pierrorinfoall); if (pierrorinfoall!= NULL) { // Test to see if it's a valid OLE DB IErrorInfo interface exposing a list of records. if (SUCCEEDED(pIErrorInfoAll->QueryInterface(IID_IErrorRecords, (void**) &pierrorrecords))) { pierrorrecords->getrecordcount(&nrecs); // Within each record, retrieve information from each of the defined interfaces.

19 // Within each record, retrieve information from each of the defined interfaces. for (nrec = 0; nrec < nrecs; nrec++) { // From IErrorRecords, get the HRESULT and a reference to the ISQLErrorInfo interface. pierrorrecords->getbasicerrorinfo(nrec, &errorinfo); pierrorrecords->getcustomerrorobject(nrec,iid_isqlerrorinfo, (IUnknown**) &pisqlerrorinfo); // Display the HRESULT, then use the ISQLErrorInfo. wprintf(l"hresult:\t%#x\n", errorinfo.hrerror); if (pisqlerrorinfo!= NULL) { pisqlerrorinfo->getsqlinfo(&bstrsqlstate, &lnativeerror); // Display the SQLSTATE and native error values. wprintf(l"sqlstate:\t%s\nnative Error:\t%ld\n", bstrsqlstate, lnativeerror); // SysFree BSTR references. SysFreeString(bstrSQLSTATE); // Get the ISQLServerErrorInfo interface from ISQLErrorInfo before releasing the reference. pisqlerrorinfo->queryinterface( IID_ISQLServerErrorInfo, (void**) &pisqlservererrorinfo); pisqlerrorinfo->release(); // Test to ensure the reference is valid, then get error information from ISQLServerErrorInfo. if (pisqlservererrorinfo!= NULL) { pisqlservererrorinfo->geterrorinfo(&psserrorinfo, &psserrorstrings); // ISQLServerErrorInfo::GetErrorInfo succeeds even when it has nothing to return. // Test the pointers before using. if (psserrorinfo) { // Display the state and severity from the returned information. // The error message comes from IErrorInfo::GetDescription. wprintf(l"error state:\t%d\nseverity:\t%d\n", psserrorinfo->bstate, psserrorinfo->bclass); // IMalloc::Free needed to release references on returned values. CoTaskMemFree(pSSErrorStrings); CoTaskMemFree(pSSErrorInfo); pisqlservererrorinfo->release(); if (SUCCEEDED(pIErrorRecords->GetErrorInfo(nRec, MYLOCALEID, &pierrorinforecord))) { // Get the source and description (error message) from the record's IErrorInfo. pierrorinforecord->getsource(&bstrsource); pierrorinforecord->getdescription(&bstrdescription); if (bstrsource!= NULL) { wprintf(l"source:\t\t%s\n", bstrsource); SysFreeString(bstrSource); if (bstrdescription!= NULL) { wprintf(l"error message:\t%s\n", bstrdescription); SysFreeString(bstrDescription); pierrorinforecord->release(); pierrorrecords->release(); else { // IErrorInfo is valid; get the source and description to see what it is. pierrorinfoall->getsource(&bstrsource); pierrorinfoall->getdescription(&bstrdescription); if (bstrsource!= NULL) { wprintf(l"source:\t\t%s\n", bstrsource);

20 wprintf(l"source:\t\t%s\n", bstrsource); SysFreeString(bstrSource); if (bstrdescription!= NULL) { wprintf(l"error message:\t%s\n", bstrdescription); SysFreeString(bstrDescription); pierrorinfoall->release(); else wprintf(l"geterrorinfo has not returned ErrorInfo.\n"); pisupporterrorinfo->release(); return; void Test_GetRowset(IDBSchemaRowset *pdbschemarowset, DBCOUNTITEM cexpectedrows) { HRESULT hr; IRowset * prowset = NULL; IAccessor * paccessor = NULL; HACCESSOR haccessor = NULL; struct srowdata { wchar_t wszcolumnname [128]; VARIANT_BOOL fissparse; VARIANT_BOOL fiscolumnset; rowdata; DBBINDING rgbindings[3] = { {4, offsetof(srowdata, wszcolumnname), 0, 0, 0, 0, 0, DBPART_VALUE,DBMEMOWNER_CLIENTOWNED, DBPARAMIO_NOTPARAM, sizeof(rowdata.wszcolumnname),0, DBTYPE_WSTR, 0, 0, {41, offsetof(srowdata, fissparse),0, 0, 0, 0, 0, DBPART_VALUE,DBMEMOWNER_CLIENTOWNED, DBPARAMIO_NOTPARAM, sizeof(rowdata.fissparse), 0, DBTYPE_BOOL, 0, 0, {42, offsetof(srowdata, fiscolumnset),0, 0, 0, 0, 0, DBPART_VALUE,DBMEMOWNER_CLIENTOWNED, DBPARAMIO_NOTPARAM, sizeof(rowdata.fiscolumnset),0, DBTYPE_BOOL, 0, 0 ; DBCOUNTITEM irow; BSTR bstrtable = SysAllocString(L"tbl_sparse_test"); CHECK_NOT_NULL(bstrTable); tagvariant rgrestrictions[3]; VariantInit(rgRestrictions); VariantInit(rgRestrictions+1); VariantInit(rgRestrictions+2); rgrestrictions[0].vt = VT_EMPTY; rgrestrictions[1].vt = VT_EMPTY; rgrestrictions[2].vt = VT_BSTR; rgrestrictions[2].bstrval = bstrtable; wprintf(l"\ntesting %ls\n", cexpectedrows == 3? L"DBSCHEMA_COLUMNS_EXTENDED" : L"DBSCHEMA_SPARSE_COLUMN_SET"); CHECKED(pdbSchemaRowset->GetRowset( NULL, cexpectedrows == 3? DBSCHEMA_COLUMNS_EXTENDED: DBSCHEMA_SPARSE_COLUMN_SET, 3, rgrestrictions, IID_IRowset, 0, NULL, (IUnknown**)&pRowset)

21 (IUnknown**)&pRowset) ); DBCOUNTITEM crowsobtained = 0; HROW rgrows[3]; HROW * prows = rgrows; CHECKED(pRowset->GetNextRows( 0, 0, cexpectedrows, &crowsobtained, &prows)); if (crowsobtained!= cexpectedrows) CHECKED(E_UNEXPECTED); CHECKED(pRowset->QueryInterface(IID_IAccessor, (void**)&paccessor)); CHECKED(pAccessor ->CreateAccessor( DBACCESSOR_ROWDATA, 3, rgbindings, sizeof(rowdata), &haccessor, NULL)); for (irow = 0 ; irow < cexpectedrows; irow++) { CHECKED(pRowset->GetData( rgrows[irow], haccessor, (void*)&rowdata)); wprintf(l"column %ls,\tissparse=%ls, \tiscolumnset=%ls\n", rowdata.wszcolumnname, (rowdata.fissparse? L"TRUE " : L"FALSE"), (rowdata.fiscolumnset? L"TRUE " : L"FALSE")); ERR: if (bstrtable) SysFreeString(bstrTable); SAFE_RELEASE(pAccessor); SAFE_RELEASE(pRowset); int cdecl main() { HRESULT hr; IDBInitialize * pidbinit = NULL; IDataInitialize * pidi = NULL; IDBCreateSession * pidbcreatesession = NULL; IDBCreateCommand * pidbcreatecommand = NULL; ICommandText * pcommand = NULL; IDBSchemaRowset * pdbschemarowset = NULL; IOpenRowset * popenrowset = NULL; IColumnsInfo * pcolumnsinfo = NULL; ULONG cschemas; ULONG cfoundschemas = 0; GUID * rgschemas = NULL; ULONG * rgrestsupport = NULL; DBID dbidsparse; DBORDINAL ccolumns, i; WCHAR * pnamebuff = NULL; DBCOLUMNINFO * prgcolinfo = NULL; CHECKED(CoInitializeEx(NULL, COINIT_MULTITHREADED)); CHECKED(CoCreateInstance(CLSID_MSDAINITIALIZE, NULL, CLSCTX_INPROC_SERVER, IID_IDataInitialize, (void**)&pidi)); CHECKED(pIDI->GetDataSource(NULL, CLSCTX_INPROC_SERVER, L"Provider=SQLNCLI11; Integrated Security=SSPI; Data Source=.; Initial Catalog=tempdb", IID_IDBInitialize, (IUnknown**)&pIDBInit)); CHECKED(pIDBInit->Initialize()); CHECKED(pIDBInit->QueryInterface(IID_IDBCreateSession, (void**)&pidbcreatesession)); CHECKED(pIDBCreateSession->CreateSession(NULL, IID_IDBCreateCommand, (IUnknown**)&pIDBCreateCommand)); CHECKED(pIDBCreateCommand->CreateCommand(NULL, IID_ICommandText, (IUnknown**)&pCommand)); // Drop the old table if it exists CHECKED(pCommand->SetCommandText(DBGUID_DBSQL, L"if object_id('tempdb.dbo.tbl_sparse_test','u') is not null drop table tempdb.dbo.tbl_sparse_test")); CHECKED(pCommand->Execute(NULL, IID_NULL, NULL, NULL, NULL)); // Create a new table CHECKED(pCommand->SetCommandText(DBGUID_DBSQL, L"create table tempdb.dbo.tbl_sparse_test (col1 int SPARSE, col2 int, col3 XML column_set for all_sparse_columns)")); CHECKED3(pCommand->Execute(NULL, IID_NULL, NULL, NULL, NULL), pcommand, IID_ICommandText);

22 // Insert a row into the table CHECKED(pCommand->SetCommandText(DBGUID_DBSQL, L"insert tempdb.dbo.tbl_sparse_test (col1, col2) values (1,2)")); CHECKED3(pCommand->Execute(NULL, IID_NULL, NULL, NULL, NULL), pcommand, IID_ICommandText); // Let's check the schemas support CHECKED(pIDBCreateCommand->QueryInterface(IID_IDBSchemaRowset, (void**)&pdbschemarowset)); CHECKED(pdbSchemaRowset->GetSchemas(&cSchemas, &rgschemas, &rgrestsupport)); while (cschemas--) { if (rgschemas[cschemas]== DBSCHEMA_COLUMNS_EXTENDED rgschemas[cschemas]== DBSCHEMA_SPARSE_COLUMN_SET) { if (++cfoundschemas == 2) break; if (cfoundschemas!= 2) { wprintf(l"found %d of expected 2 new DBSCHEMAs\n", cfoundschemas); goto ERR; // Test the schemas: Test_GetRowset(pdbSchemaRowset, 1); Test_GetRowset(pdbSchemaRowset, 3); // Test the column info CHECKED(pIDBCreateCommand->QueryInterface(IID_IOpenRowset, (void**)&popenrowset)); dbidsparse.ekind = DBKIND_NAME; dbidsparse.uname.pwszname = L"tbl_sparse_test"; // This will result in "select * from tbl_sparse_test" CHECKED(pOpenRowset->OpenRowset( NULL, &dbidsparse, NULL, IID_IColumnsInfo, 0, NULL, (IUnknown**)&pColumnsInfo)); CHECKED(pColumnsInfo->GetColumnInfo(&cColumns, &prgcolinfo, &pnamebuff)); wprintf(l"\ntesting GetColumnInfo:\n"); for ( i = 0 ; i < ccolumns ; i++) { wprintf(l"column name: %ls, flags: ",prgcolinfo[i].pwszname); DWORD dwflags = prgcolinfo[i].dwflags; PRINT_FLAGS(dwFlags, DBCOLUMNFLAGS_ISFIXEDLENGTH); PRINT_FLAGS(dwFlags, DBCOLUMNFLAGS_WRITEUNKNOWN); PRINT_FLAGS(dwFlags, DBCOLUMNFLAGS_WRITE); PRINT_FLAGS(dwFlags, DBCOLUMNFLAGS_MAYBENULL); PRINT_FLAGS(dwFlags, DBCOLUMNFLAGS_ISLONG); PRINT_FLAGS(dwFlags, DBCOLUMNFLAGS_ISNULLABLE); PRINT_FLAGS(dwFlags, DBCOLUMNFLAGS_SS_ISCOLUMNSET); wprintf(l"\n"); ERR: PROVIDER_FREE(prgColInfo); PROVIDER_FREE(pNameBuff); SAFE_RELEASE(pColumnsInfo); SAFE_RELEASE(pOpenRowset); PROVIDER_FREE(rgSchemas); PROVIDER_FREE(rgRestSupport); SAFE_RELEASE(pdbSchemaRowset); SAFE_RELEASE(pCommand); SAFE_RELEASE(pIDBCreateCommand); SAFE_RELEASE(pIDBCreateSession); SAFE_RELEASE(pIDI); SAFE_RELEASE(pIDBInit); CoUninitialize();

23

24 Enumerate OLE DB Data Sources (OLE DB) 1/24/ min to read Edit Online THIS TOPIC APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data Warehouse This sample shows how to use the enumerator object to list the data sources available. To list the data sources visible to the SQLOLEDB enumerator, the consumer calls the ISourcesRowset::GetSourcesRowset method. This method returns a rowset of information about the currently visible data sources. Depending on the network library used, the appropriate domain is searched for the data sources. For named pipes, it is the domain to which the client is logged on. For AppleTalk, it is the default zone. For SPX/IPX, it is the list of SQL Server installations found in the bindery. For Banyan VINES, it is the SQL Server installations found on the local network. Multiprotocol and TCP/IP sockets are not supported. When the server is turned off or on, it can take few minutes to update the information in these domains. This sample requires the AdventureWorks sample database, which you can download from the Microsoft SQL Server Samples and Community Projects home page. IMPORTANT When possible, use Windows Authentication. If Windows Authentication is not available, prompt users to enter their credentials at run time. Avoid storing credentials in a file. If you must persist credentials, you should encrypt them with the Win32 crypto API. To enumerate OLE DB data sources 1. Retrieve the source rowset by calling ISourceRowset::GetSourcesRowset. 2. Find the description of the enumerators rowset by calling GetColumnInfo::IColumnInfo. 3. Create the binding structures from the column information. 4. Create the rowset accessor by calling IAccessor::CreateAccessor. 5. Fetch the rows by calling IRowset::GetNextRows. 6. Retrieve data from the rowset's copy of the row by calling IRowset::GetData, and process it. Example Compile with ole32.lib and execute the following C++ code listing. This application connects to your computer's default SQL Server instance. On some Windows operating systems, you will need to change (localhost) or (local) to the name of your SQL Server instance. To connect to a named instance, change the connection string from L" (local)" to L"(local)\\name", where name is the named instance. By default, SQL Server Express installs to a named instance. Make sure your INCLUDE environment variable includes the directory that contains sqlncli.h. // compile with: ole32.lib #define UNICODE #define _UNICODE #define DBINITCONSTANTS #define INITGUID #define OLEDBVER 0x0250 // to include correct interfaces

25 #define OLEDBVER 0x0250 // to include correct interfaces #include <windows.h> #include <stddef.h> #include <oledb.h> #include <oledberr.h> #include <sqlncli.h> #include <stdio.h> #define NUMROWS_CHUNK 5 // AdjustLen supports binding on four-byte boundaries. _inline DBLENGTH AdjustLen(DBLENGTH cb) { return ( (cb + 3) & ~3 ); // Get the characteristics of the rowset (the IColumnsInfo interface). HRESULT GetColumnInfo ( IRowset* pirowset, DBORDINAL* pncols, DBCOLUMNINFO** ppcolumnsinfo, OLECHAR** ppcolumnstrings ) { IColumnsInfo* picolumnsinfo; HRESULT hr; *pncols = 0; if (FAILED(pIRowset->QueryInterface(IID_IColumnsInfo, (void**) &picolumnsinfo))) return (E_FAIL); hr = picolumnsinfo->getcolumninfo(pncols, ppcolumnsinfo, ppcolumnstrings); if (FAILED(hr)) { /* Process error */ picolumnsinfo->release(); return (hr); // Create binding structures from column information. Binding structures // will be used to create an accessor that allows row value retrieval. void CreateDBBindings ( DBORDINAL ncols, DBCOLUMNINFO* pcolumnsinfo, DBBINDING** ppdbbindings, BYTE** pprowvalues ) { ULONG ncol; DBLENGTH cbrow = 0; DBLENGTH cbcol; DBBINDING* pdbbindings; BYTE* prowvalues; pdbbindings = new DBBINDING[nCols]; if (!(pdbbindings /* = new DBBINDING[nCols] */ )) return; for ( ncol = 0 ; ncol < ncols ; ncol++ ) { pdbbindings[ncol].iordinal = ncol + 1; pdbbindings[ncol].ptypeinfo = NULL; pdbbindings[ncol].pobject = NULL; pdbbindings[ncol].pbindext = NULL; pdbbindings[ncol].dwpart = DBPART_VALUE; pdbbindings[ncol].dwmemowner = DBMEMOWNER_CLIENTOWNED; pdbbindings[ncol].eparamio = DBPARAMIO_NOTPARAM; pdbbindings[ncol].dwflags = 0; pdbbindings[ncol].wtype = pcolumnsinfo[ncol].wtype; pdbbindings[ncol].bprecision = pcolumnsinfo[ncol].bprecision; pdbbindings[ncol].bscale = pcolumnsinfo[ncol].bscale; cbcol = pcolumnsinfo[ncol].ulcolumnsize; switch (pcolumnsinfo[ncol].wtype) { case DBTYPE_STR: { cbcol += 1;

26 cbcol += 1; break; case DBTYPE_WSTR: { cbcol = (cbcol + 1) * sizeof(wchar); break; default: break; pdbbindings[ncol].obvalue = cbrow; pdbbindings[ncol].cbmaxlen = cbcol; cbrow += AdjustLen(cbCol); prowvalues = new BYTE[cbRow]; *ppdbbindings = pdbbindings; *pprowvalues = prowvalues; int main() { ISourcesRowset* pisourcerowset = NULL; IRowset* pirowset = NULL; IAccessor* piaccessor = NULL; DBBINDING* pdbbindings = NULL; HROW* prows = new HROW[500]; HACCESSOR haccessorretrieve = NULL; ULONG DSSeqNumber = 0; HRESULT hr; DBORDINAL ncols; DBCOLUMNINFO* pcolumnsinfo = NULL; OLECHAR* pcolumnstrings = NULL; DBBINDSTATUS* pdbbindstatus = NULL; BYTE* prowvalues = NULL; DBCOUNTITEM crowsobtained; ULONG irow; char* pmultibyte = NULL; short* pssourcetype = NULL; BYTE* pdatasource = NULL; if (!prows) return (0); // Initialize COM library. CoInitialize(NULL); // Initialize the enumerator. if (FAILED(CoCreateInstance(CLSID_SQLNCLI11_ENUMERATOR, NULL, CLSCTX_INPROC_SERVER, IID_ISourcesRowset, (void**)&pisourcerowset))) { // Process error. return TRUE; // Retrieve the source rowset. hr = pisourcerowset->getsourcesrowset(null, IID_IRowset, 0, NULL, (IUnknown**)&pIRowset); pisourcerowset->release(); if (FAILED(hr)) { // Process error. return TRUE;

27 // Get the description of the enumerator's rowset. if (FAILED(hr = GetColumnInfo(pIRowset, &ncols, &pcolumnsinfo, &pcolumnstrings))) { // Process error. goto SAFE_EXIT; // Create the binding structures. CreateDBBindings(nCols, pcolumnsinfo, &pdbbindings, &prowvalues); pdbbindstatus = new DBBINDSTATUS[nCols]; if (sizeof(tchar)!= sizeof(wchar)) pmultibyte = new char[pdbbindings[0].cbmaxlen]; if (FAILED(pIRowset->QueryInterface(IID_IAccessor, (void**)&piaccessor))) { // Process error. goto SAFE_EXIT; // Create the rowset accessor. if (FAILED(hr = piaccessor->createaccessor(dbaccessor_rowdata, ncols, pdbbindings, 0, &haccessorretrieve, pdbbindstatus))) { // Process error. goto SAFE_EXIT; // Process all the rows, NUMROWS_CHUNK rows at a time. while (SUCCEEDED(hr)) { hr = pirowset->getnextrows(null, 0, NUMROWS_CHUNK, &crowsobtained, &prows); if( FAILED(hr)) { // process error if (crowsobtained == 0 FAILED(hr)) break; for (irow = 0 ; irow < crowsobtained ; irow++) { // Get the rowset data. if (SUCCEEDED(hr = pirowset->getdata(prows[irow], haccessorretrieve, prowvalues))) { pssourcetype = (short *)(prowvalues + pdbbindings[3].obvalue); if (*pssourcetype == DBSOURCETYPE_DATASOURCE) { DSSeqNumber = DSSeqNumber + 1; // Data source counter. pdatasource = (prowvalues + pdbbindings[0].obvalue); if ( sizeof(tchar)!= sizeof(wchar) ) { WideCharToMultiByte(CP_ACP, 0, (WCHAR*)pDatasource, -1, pmultibyte, static_cast<int>(pdbbindings[0].cbmaxlen), NULL, NULL); printf( "DataSource# %d\tname: %S\n", DSSeqNumber, (WCHAR *) pmultibyte ); else { printf( "DataSource# %d\tname: %S\n", DSSeqNumber, (WCHAR *) pdatasource );

28 pirowset->releaserows(crowsobtained, prows, NULL, NULL, NULL); // Release COM library. CoUninitialize(); SAFE_EXIT: // Do the clean-up. return TRUE;

29 Fetch Columns Using IRow::GetColumns (OLE DB) 1/24/ min to read Edit Online THIS TOPIC APPLIES TO: SQL Server Azure SQL Database Azure SQL Data Warehouse Parallel Data Warehouse The IRow interface allows direct access to columns of a single row in the result set. Thus, IRow is an efficient way to retrieve columns from a result set with one row. A code sample is available that showshow to fetch a single row using IRow. In this sample, one column at a time is retrieved from the row. The sample shows: How to fetch a group of columns (in sequence). How to access a column twice. The first time the actual column width is obtained, and later the actual data is accessed. In the DBCOLUMNACCESS structure, if pdata is NULL and cbmaxlen is 0, the call to IRow->GetColumns() returns only the actual column length. In this case, IRow->GetColumns() can be called again on the same column to retrieve the actual data. IMPORTANT When possible, use Windows Authentication. If Windows Authentication is not available, prompt users to enter their credentials at run time. Avoid storing credentials in a file. If you must persist credentials, you should encrypt them with the Win32 crypto API. To fetch columns using IRow::GetColumns 1. Establish a connection to the data source. 2. Execute the command (in the following example, ICommandExecute::Execute() is called with IID_IRow). 3. Execute IRow::GetColumns() to fetch one or more columns in the resulting row. If you want to find the actual column size before fetching data, set the pdata in DBCOLUMNACCESS to NULL. The call to IRow::GetColumns() returns only the column width. Another call the IRow::GetColumns() will fetch the data. 4. Execute IRow::GetColumns() until all the columns you need are accessed. The columns must be accessed in sequence. Example This sample shows how to use the IRow interface to allow direct access to columns of a single row in the result set. The example shows: How to fetch a group of columns in sequence. How to access a column twice - the first time the actual column width is obtained and then later the actual data is accessed. In the DBCOLUMNACCESS structure, if pdata is NULL and cbmaxlen is 0, the call to IRow->GetColumns returns only the actual column length. In this case IRow->GetColumns can be called again on the same column to retrieve the actual data. This sample is not supported on IA64. This sample requires the AdventureWorks sample database, which you can download from the Microsoft SQL Server Samples and Community Projects home page.

30 The first ( Transact-SQL) code listing creates a table used by the sample. Compile with ole32.lib oleaut32.lib and execute the second (C++) code listing. This application connects to your computer's default SQL Server instance. On some Windows operating systems, you will need to change (localhost) or (local) to the name of your SQL Server instance. To connect to a named instance, change the connection string from L"(local)" to L"(local)\\name", where name is the named instance. By default, SQL Server Express installs to a named instance. Make sure your INCLUDE environment variable includes the directory that contains sqlncli.h. The third ( Transact-SQL) code listing deletes the table used by the sample. use AdventureWorks go if exists (select name from sysobjects where name = 'MyTable') drop table MyTable go create table MyTable ( col1 int, col2 varchar(50), col3 char(50), col4 datetime, col5 float, col6 money, col7 sql_variant, col8 binary(50), col9 text, col10 image ) go insert into MyTable values ( 10, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', '11/1/ :52 AM', 3.14, 99.95, convert(nchar(50), N'AbCdEfGhIjKlMnOpQrStUvWxYz'), 0x , replicate('aaaaabbbbb', 500), replicate(0x , 500) ) Go // compile with: ole32.lib oleaut32.lib #define DBINITCONSTANTS #define OLEDBVER 0x0250 // to include correct interfaces #include <stdio.h> #include <windows.h> #include <iostream> #include <oledb.h> #include <sqlncli.h> using namespace std; int InitializeAndEstablishConnection(); HRESULT GetColumnSize(IRow* punkrow, ULONG icol); ULONG PrintData(ULONG icols, ULONG istart, DBCOLUMNINFO* prginfo, DBCOLUMNACCESS* prgcolumns); HRESULT GetColumns(IRow* punkrow, ULONG istart, ULONG iend);

Tables and Indexes Adding a Column to a SQL Server Table Creating SQL Server Indexes Creating SQL Server Tables Dropping a SQL Server Index Dropping

Tables and Indexes Adding a Column to a SQL Server Table Creating SQL Server Indexes Creating SQL Server Tables Dropping a SQL Server Index Dropping Table of Contents Tables and Indexes Adding a Column to a SQL Server Table Creating SQL Server Indexes Creating SQL Server Tables Dropping a SQL Server Index Dropping a SQL Server Table Removing a Column

More information

DBMaker OLEDB User's Guide

DBMaker OLEDB User's Guide DBMaker OLEDB User's Guide CASEMaker Inc./Corporate Headquarters 1680 Civic Center Drive Santa Clara, CA 95050, U.S.A. www.casemaker.com www.casemaker.com/support Copyright 1995-2012 by CASEMaker Inc.

More information

ARKER. OLE DB for the Context Interchange System. Chiuyi Chan. Submitted to the Department of Electrical Engineering and Computer Science

ARKER. OLE DB for the Context Interchange System. Chiuyi Chan. Submitted to the Department of Electrical Engineering and Computer Science OLE DB for the Context Interchange System by Chiuyi Chan Submitted to the Department of Electrical Engineering and Computer Science in Partial Fulfillment of the Requirements for the Degrees of Bachelor

More information

Department of Computer Science University of Cyprus. EPL342 Databases. Lab 1. Introduction to SQL Server Panayiotis Andreou

Department of Computer Science University of Cyprus. EPL342 Databases. Lab 1. Introduction to SQL Server Panayiotis Andreou Department of Computer Science University of Cyprus EPL342 Databases Lab 1 Introduction to SQL Server 2008 Panayiotis Andreou http://www.cs.ucy.ac.cy/courses/epl342 1-1 Before We Begin Start the SQL Server

More information

Informix OLE DB Provider Programmer s Guide

Informix OLE DB Provider Programmer s Guide Informix OLE DB Provider Programmer s Guide Version 2.0 May 1999 Part No. 000-5445 Published by INFORMIX Press Informix Corporation 4100 Bohannon Drive Menlo Park, CA 94025-1032 1999 Informix Corporation.

More information

http://www.drdobbs.com/cpp/184401572 class Foo public: bool Bar() IUnknown * punk = NULL; HRESULT hr = CoCreateInstance(SOME_CLSID, NULL, CLSCTX_LOCAL_SERVER, SOME_IID, (LPVOID*)&pUnk); if (SUCCEEDED(hr))

More information

Capturing Event Data

Capturing Event Data Capturing Event Data Introduction: Morae Recorder supports the use of plug-ins to capture additional event data beyond Morae s standard RRT information during a recording session. This mechanism can be

More information

DirectPlay. What is DirectPlay? Vishnu Kotrajaras, PhD

DirectPlay. What is DirectPlay? Vishnu Kotrajaras, PhD DirectPlay Vishnu Kotrajaras, PhD What is DirectPlay? It is a multiplayer component of DirectX It abstracts communication methods away Same function call for communication by TCP/IP, serial cable and modem

More information

Tables. Tables. Physical Organization: SQL Server Partitions

Tables. Tables. Physical Organization: SQL Server Partitions Tables Physical Organization: SQL Server 2005 Tables and indexes are stored as a collection of 8 KB pages A table is divided in one or more partitions Each partition contains data rows in either a heap

More information

Physical Organization: SQL Server 2005

Physical Organization: SQL Server 2005 Physical Organization: SQL Server 2005 Tables Tables and indexes are stored as a collection of 8 KB pages A table is divided in one or more partitions Each partition contains data rows in either a heap

More information

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14 C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition

More information

DirectX Programming Introduction

DirectX Programming Introduction DirectX Programming Introduction DirectX is implemented as a collection of COM objects To use a DirectX program, the user must have the correct (or later) version of DirectX installed (e.g. by doing Windows

More information

IBM. Using UniOLEDB. Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

IBM. Using UniOLEDB. Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta C:\Program Files\Adobe\FrameMaker8\UniVerse 10.3\unioledb\OLDBTITL.fm February 4, 2009 3:25 pm Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta IBM Using UniOLEDB UniVerse

More information

LIN2CAN API (L2CAPI) MANUAL ENGLISH

LIN2CAN API (L2CAPI) MANUAL ENGLISH LIN2CAN API (L2CAPI) MANUAL ENGLISH HMS Technology Center Ravensburg GmbH Helmut-Vetter-Straße 2 88213 Ravensburg Germany Tel.: +49 751 56146-0 Fax: +49 751 56146-29 Internet: www.hms-networks.de E-Mail:

More information

Integration Services. Creating an ETL Solution with SSIS. Module Overview. Introduction to ETL with SSIS Implementing Data Flow

Integration Services. Creating an ETL Solution with SSIS. Module Overview. Introduction to ETL with SSIS Implementing Data Flow Pipeline Integration Services Creating an ETL Solution with SSIS Module Overview Introduction to ETL with SSIS Implementing Data Flow Lesson 1: Introduction to ETL with SSIS What Is SSIS? SSIS Projects

More information

6.096 Introduction to C++ January (IAP) 2009

6.096 Introduction to C++ January (IAP) 2009 MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture

More information

[MS-RAINPS]: Remote Administrative Interface: Network Policy Server (NPS) Protocol

[MS-RAINPS]: Remote Administrative Interface: Network Policy Server (NPS) Protocol [MS-RAINPS]: Remote Administrative Interface: Network Policy Server (NPS) Protocol Intellectual Property Rights Notice for Open Specifications Documentation Technical Documentation. Microsoft publishes

More information

SQL in Programming Languages Read chapter 5 of Atzeni et al. BD: Modelli e Linguaggi di Interrogazione and section 8.

SQL in Programming Languages Read chapter 5 of Atzeni et al. BD: Modelli e Linguaggi di Interrogazione and section 8. SQL in Programming Languages Read chapter 5 of Atzeni et al. BD: Modelli e Linguaggi di Interrogazione and section 8.4 of Garcia-Molina Slides derived from those by Jeffrey D. Ullman SQL and Programming

More information

SQream Connector Native C SQream Technologies Version 1.2.0

SQream Connector Native C SQream Technologies Version 1.2.0 SQream Connector Native C++ 1.2.0 SQream Technologies 2019-03-27 Version 1.2.0 Table of Contents The SQream Native C++ Connector - Overview................................................. 1 1. API Reference............................................................................

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

Armide Documentation. Release Kyle Mayes

Armide Documentation. Release Kyle Mayes Armide Documentation Release 0.3.1 Kyle Mayes December 19, 2014 Contents 1 Introduction 1 1.1 Features.................................................. 1 1.2 License..................................................

More information

Call DLL from Limnor Applications

Call DLL from Limnor Applications Call DLL from Limnor Applications There is a lot of computer software in the format of dynamic link libraries (DLL). DLLCaller performer allows your applications to call DLL functions directly. Here we

More information

PSK Propagation Reporter DLL Documentation 2013-Mar-10 Philip Gladstone

PSK Propagation Reporter DLL Documentation 2013-Mar-10 Philip Gladstone PSK Propagation Reporter DLL Documentation 2013-Mar-10 Philip Gladstone This describes the PSK Propagation Reporter API that is available on Windows and which is provided by

More information

Get Table Schema In Sql Server 2008 To Add Column If Not Exists >>>CLICK HERE<<<

Get Table Schema In Sql Server 2008 To Add Column If Not Exists >>>CLICK HERE<<< Get Table Schema In Sql Server 2008 To Add Column If Not Exists IF NOT EXISTS ( SELECT * FROM sys.columns WHERE object_id = OBJECT_ID(N'(dbo). Also try catch is easily possible to use in sql serverand

More information

Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable

Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable Basic C++ Overview C++ is a version of the older C programming language. This is a language that is used for a wide variety of applications and which has a mature base of compilers and libraries. C++ is

More information

CA Data Protection. External Agent COM API Reference Guide. Release 15.0

CA Data Protection. External Agent COM API Reference Guide. Release 15.0 CA Data Protection External Agent COM API Reference Guide Release 15.0 This Documentation, which includes embedded help systems and electronically distributed materials (hereinafter referred to as the

More information

Amazon Redshift ODBC Driver 1.3.6

Amazon Redshift ODBC Driver 1.3.6 Amazon Redshift ODBC Driver 1.3.6 Released August 10, 2017 These release notes provide details of enhancements, features, and known issues in Amazon Redshift ODBC Driver 1.3.6, as well as the version history.

More information

CSCI 2212: Intermediate Programming / C Review, Chapters 10 and 11

CSCI 2212: Intermediate Programming / C Review, Chapters 10 and 11 ... 1/16 CSCI 2212: Intermediate Programming / C Review, Chapters 10 and 11 Alice E. Fischer February 3, 2016 ... 2/16 Outline Basic Types and Diagrams ... 3/16 Basic Types and Diagrams Types in C C has

More information

THE INTEGER DATA TYPES. Laura Marik Spring 2012 C++ Course Notes (Provided by Jason Minski)

THE INTEGER DATA TYPES. Laura Marik Spring 2012 C++ Course Notes (Provided by Jason Minski) THE INTEGER DATA TYPES STORAGE OF INTEGER TYPES IN MEMORY All data types are stored in binary in memory. The type that you give a value indicates to the machine what encoding to use to store the data in

More information

Kurt Schmidt. October 30, 2018

Kurt Schmidt. October 30, 2018 to Structs Dept. of Computer Science, Drexel University October 30, 2018 Array Objectives to Structs Intended audience: Student who has working knowledge of Python To gain some experience with a statically-typed

More information

advanced data types (2) typedef. today advanced data types (3) enum. mon 23 sep 2002 defining your own types using typedef

advanced data types (2) typedef. today advanced data types (3) enum. mon 23 sep 2002 defining your own types using typedef today advanced data types (1) typedef. mon 23 sep 2002 homework #1 due today homework #2 out today quiz #1 next class 30-45 minutes long one page of notes topics: C advanced data types dynamic memory allocation

More information

An overview of how to write your function and fill out the FUNCTIONINFO structure. Allocating and freeing memory.

An overview of how to write your function and fill out the FUNCTIONINFO structure. Allocating and freeing memory. Creating a User DLL Extend Mathcad Professional's power by writing your own customized functions. Your functions will have the same advanced features as Mathcad built-in functions, such as customized error

More information

This is CS50. Harvard University Fall Quiz 0 Answer Key

This is CS50. Harvard University Fall Quiz 0 Answer Key Quiz 0 Answer Key Answers other than the below may be possible. Binary Bulbs. 0. Bit- Sized Questions. 1. Because 0 is non- negative, we need to set aside one pattern of bits (000) for it, which leaves

More information

MFC Programmer s Guide: Getting Started

MFC Programmer s Guide: Getting Started MFC Programmer s Guide: Getting Started MFC PROGRAMMERS GUIDE... 2 PREPARING THE DEVELOPMENT ENVIRONMENT FOR INTEGRATION... 3 INTRODUCING APC... 4 GETTING VISUAL BASIC FOR APPLICATIONS INTO YOUR MFC PROJECT...

More information

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9 Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Uppercase Alphabets Lowercase Alphabets Character Set A, B, C, Y, Z a, b, c, y, z Digits

More information

Transbase R PHP Module

Transbase R PHP Module Transbase R PHP Module Transaction Software GmbH Willy-Brandt-Allee 2 D-81829 München Germany Phone: +49-89-62709-0 Fax: +49-89-62709-11 Email: info@transaction.de http://www.transaction.de Version 7.1.2.30

More information

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures The main body and cout Agenda 1 Fundamental data types Declarations and definitions Control structures References, pass-by-value vs pass-by-references The main body and cout 2 C++ IS AN OO EXTENSION OF

More information

Introduction to C++ Systems Programming

Introduction to C++ Systems Programming Introduction to C++ Systems Programming Introduction to C++ Syntax differences between C and C++ A Simple C++ Example C++ Input/Output C++ Libraries C++ Header Files Another Simple C++ Example Inline Functions

More information

New Features PowerBuilder 12.0

New Features PowerBuilder 12.0 New Features PowerBuilder 12.0 Document ID: DC00357-01-1200-01 Last revised: March 2010 Topic Page PowerBuilder Classic and PowerBuilder.NET 1 Platform support 2 Enhancements for the ADO.NET Interface

More information

int fnvgetconfig(handle h, UINT32 id, const void *cfg, size_t sz);... 4

int fnvgetconfig(handle h, UINT32 id, const void *cfg, size_t sz);... 4 RP-VL-UTIL-V1 Developer s Guide [ Contents ] 1. Introduction... 1 2. Building Environment... 1 3. Operating Environment... 1 4. Function Explanation... 2 4.1. Common API for Transmitting and Receiving...

More information

COM & COM+ (Component Object Model) Bazsó-Dombi András, Group 251.

COM & COM+ (Component Object Model) Bazsó-Dombi András, Group 251. COM & COM+ (Component Object Model) Bazsó-Dombi András, Group 251. What is COM? Low level Objects created independently need to be used in other applications Create an object, add some special attributes

More information

James

James https://www.flickr.com/photos/giuseppemilo/40760404654 James Forshaw @tiraniddo Who am I? Researcher in Google s Project Zero Specialize in Windows Especially local privilege escalation Logical vulnerability

More information

Outline. COM overview. DCOM overview. Comparison DCOM and Corba

Outline. COM overview. DCOM overview. Comparison DCOM and Corba DCOM Overview 1 Outline COM overview DCOM overview Comparison DCOM and Corba 2 COM overview Standard for component interoperability binary standard specifies how the component should be represented in

More information

QCOM Reference Guide

QCOM Reference Guide QCOM Reference Guide Lars Wirfelt 2002 06 10 Copyright 2005 2016 SSAB EMEA AB Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License,

More information

#include <stdio.h> int main() { char s[] = Hsjodi, *p; for (p = s + 5; p >= s; p--) --*p; puts(s); return 0;

#include <stdio.h> int main() { char s[] = Hsjodi, *p; for (p = s + 5; p >= s; p--) --*p; puts(s); return 0; 1. Short answer questions: (a) Compare the typical contents of a module s header file to the contents of a module s implementation file. Which of these files defines the interface between a module and

More information

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19 Data Storage Geoffrey Brown Bryce Himebaugh Indiana University August 9, 2016 Geoffrey Brown, Bryce Himebaugh 2015 August 9, 2016 1 / 19 Outline Bits, Bytes, Words Word Size Byte Addressable Memory Byte

More information

Tokens, Expressions and Control Structures

Tokens, Expressions and Control Structures 3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type

More information

Rocket UniVerse. GCI Guide. Version November 2013 UNV-112-GCI-1

Rocket UniVerse. GCI Guide. Version November 2013 UNV-112-GCI-1 Rocket UniVerse GCI Guide Version 11.2 November 2013 UNV-112-GCI-1 Notices Edition Publication date: November 2013 Book number: UNV-112-GCI-1 Product version: Rocket UniVerse V11.2 2 Copyright Rocket Software,

More information

C Programming Language: C ADTs, 2d Dynamic Allocation. Math 230 Assembly Language Programming (Computer Organization) Thursday Jan 31, 2008

C Programming Language: C ADTs, 2d Dynamic Allocation. Math 230 Assembly Language Programming (Computer Organization) Thursday Jan 31, 2008 C Programming Language: C ADTs, 2d Dynamic Allocation Math 230 Assembly Language Programming (Computer Organization) Thursday Jan 31, 2008 Overview Row major format 1 and 2-d dynamic allocation struct

More information

OpenDevice Device Translator Template Guide

OpenDevice Device Translator Template Guide OpenDevice Device Translator Template Guide July 19, 2016 1 Table of Contents Device Translator Template... 8 CDeviceTranslator... 15 ~CDeviceTranslator... 16 DecodeSegmentValue... 17 GetCmd... 18 SetCmd...

More information

CO-LaN Annual meeting Sept 2014, Frankfurt, Germany

CO-LaN Annual meeting Sept 2014, Frankfurt, Germany Slide 1 IUnknown IDispatch ICapeIdentification ICape. A.k.a. the boring stuff CO-LaN Annual meeting Sept 2014, Frankfurt, Germany Slide 2 IUnknown IDispatch ICapeIdentification ICape. MicroSoft Visual

More information

OpenDevice - Device Translator Template Guide

OpenDevice - Device Translator Template Guide OpenDevice - Device Translator Template Guide Copyright 2002-2012 Lenel Systems International, Inc. 1 Table of Contents Device Translator Template... 8 CDeviceTranslator... 15 ~CDeviceTranslator... 16

More information

Update Table Schema Sql Server 2008 Add Column After

Update Table Schema Sql Server 2008 Add Column After Update Table Schema Sql Server 2008 Add Column After ALTER COLUMN ENCRYPTION KEY (Transact-SQL) Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database, the owner will remain

More information

CHAPTER 1.2 INTRODUCTION TO C++ PROGRAMMING. Dr. Shady Yehia Elmashad

CHAPTER 1.2 INTRODUCTION TO C++ PROGRAMMING. Dr. Shady Yehia Elmashad CHAPTER 1.2 INTRODUCTION TO C++ PROGRAMMING Dr. Shady Yehia Elmashad Outline 1. Introduction to C++ Programming 2. Comment 3. Variables and Constants 4. Basic C++ Data Types 5. Simple Program: Printing

More information

.Net Technologies. Components of.net Framework

.Net Technologies. Components of.net Framework .Net Technologies Components of.net Framework There are many articles are available in the web on this topic; I just want to add one more article over the web by explaining Components of.net Framework.

More information

Chapter 2. Procedural Programming

Chapter 2. Procedural Programming Chapter 2 Procedural Programming 2: Preview Basic concepts that are similar in both Java and C++, including: standard data types control structures I/O functions Dynamic memory management, and some basic

More information

C Programming SYLLABUS COVERAGE SYLLABUS IN DETAILS

C Programming SYLLABUS COVERAGE SYLLABUS IN DETAILS C Programming C SYLLABUS COVERAGE Introduction to Programming Fundamentals in C Operators and Expressions Data types Input-Output Library Functions Control statements Function Storage class Pointer Pointer

More information

[MS-SCMP-Diff]: Shadow Copy Management Protocol. Intellectual Property Rights Notice for Open Specifications Documentation

[MS-SCMP-Diff]: Shadow Copy Management Protocol. Intellectual Property Rights Notice for Open Specifications Documentation [MS-SCMP-Diff]: Intellectual Property Rights Notice for Open Specifications Documentation Technical Documentation. Microsoft publishes Open Specifications documentation ( this documentation ) for protocols,

More information

Get Table Schema In Sql Server 2005 Modify. Column Size >>>CLICK HERE<<<

Get Table Schema In Sql Server 2005 Modify. Column Size >>>CLICK HERE<<< Get Table Schema In Sql Server 2005 Modify Column Size Dynamic T-SQL - Alter column definition to max length of field VARCHAR(MAX) = '' SELECT IDENTITY(int,1,1) as ID, -- for later update 'ALTER TABLE

More information

Fundamentals of Programming CS-110. Lecture 2

Fundamentals of Programming CS-110. Lecture 2 Fundamentals of Programming CS-110 Lecture 2 Last Lab // Example program #include using namespace std; int main() { cout

More information

Basic Types, Variables, Literals, Constants

Basic Types, Variables, Literals, Constants Basic Types, Variables, Literals, Constants What is in a Word? A byte is the basic addressable unit of memory in RAM Typically it is 8 bits (octet) But some machines had 7, or 9, or... A word is the basic

More information

MsSQL Library for TIA Portal V13, V14 SP1, V15

MsSQL Library for TIA Portal V13, V14 SP1, V15 MsSQL Library for TIA Portal V13, V14 SP1, V15 User guide V1.3.2.0 Author: Tomáš Krajcar nám. Míru 1205/9 767 01 Kroměříž Czech Republic www.plc2sql.com mail: tomas.krajcar@plc2sql.com Last revision: January

More information

erwin Data Modeler API Reference Guide Release 9.7

erwin Data Modeler API Reference Guide Release 9.7 erwin Data Modeler API Reference Guide Release 9.7 This Documentation, which includes embedded help systems and electronically distributed materials (hereinafter referred to as the Documentation ), is

More information

PusleIR Multitouch Screen Software SDK Specification. Revision 4.0

PusleIR Multitouch Screen Software SDK Specification. Revision 4.0 PusleIR Multitouch Screen Software SDK Specification Revision 4.0 Table of Contents 1. Overview... 3 1.1. Diagram... 3 1.1. PulseIR API Hierarchy... 3 1.2. DLL File... 4 2. Data Structure... 5 2.1 Point

More information

Get Table Schema In Sql Server 2005 Modify. Column Datatype >>>CLICK HERE<<<

Get Table Schema In Sql Server 2005 Modify. Column Datatype >>>CLICK HERE<<< Get Table Schema In Sql Server 2005 Modify Column Datatype Applies To: SQL Server 2014, SQL Server 2016 Preview Specifies the properties of a column that are added to a table by using ALTER TABLE. Is the

More information

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program Syntax What the Compiler needs to understand your program 1 Pre-Processing Any line that starts with # is a pre-processor directive Pre-processor consumes that entire line Possibly replacing it with other

More information

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay C++ Basics Data Processing Course, I. Hrivnacova, IPN Orsay The First Program Comments Function main() Input and Output Namespaces Variables Fundamental Types Operators Control constructs 1 C++ Programming

More information

COMP322 - Introduction to C++ Lecture 02 - Basics of C++

COMP322 - Introduction to C++ Lecture 02 - Basics of C++ COMP322 - Introduction to C++ Lecture 02 - Basics of C++ School of Computer Science 16 January 2012 C++ basics - Arithmetic operators Where possible, C++ will automatically convert among the basic types.

More information

Cloudera JDBC Driver for Impala

Cloudera JDBC Driver for Impala Cloudera JDBC Driver for Impala 2.5.42 Released 2018-01-05 These release notes provide details of enhancements, features, and known issues in Cloudera JDBC Driver for Impala 2.5.42, as well as the version

More information

Programming. C++ Basics

Programming. C++ Basics Programming C++ Basics Introduction to C++ C is a programming language developed in the 1970s with the UNIX operating system C programs are efficient and portable across different hardware platforms C++

More information

Variables in C. Variables in C. What Are Variables in C? CMSC 104, Fall 2012 John Y. Park

Variables in C. Variables in C. What Are Variables in C? CMSC 104, Fall 2012 John Y. Park Variables in C CMSC 104, Fall 2012 John Y. Park 1 Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement 2 What Are Variables in C? Variables in C have the

More information

C++\CLI. Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017

C++\CLI. Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017 C++\CLI Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017 Comparison of Object Models Standard C++ Object Model All objects share a rich memory model: Static, stack, and heap Rich object life-time

More information

Cloudera JDBC Driver for Impala

Cloudera JDBC Driver for Impala Cloudera JDBC Driver for Impala 2.5.45 Released 2018-04-06 These release notes provide details of enhancements, features, and known issues in Cloudera JDBC Driver for Impala 2.5.45, as well as the version

More information

BUILDING APPLICATIONS USING C# AND.NET FRAMEWORK (OBJECT-ORIENTED PROGRAMMING, X428.6)

BUILDING APPLICATIONS USING C# AND.NET FRAMEWORK (OBJECT-ORIENTED PROGRAMMING, X428.6) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 7 Professional Program: Data Administration and Management BUILDING APPLICATIONS USING C# AND.NET FRAMEWORK (OBJECT-ORIENTED

More information

[MS-OLEPS]: Object Linking and Embedding (OLE) Property Set Data Structures

[MS-OLEPS]: Object Linking and Embedding (OLE) Property Set Data Structures [MS-OLEPS]: Object Linking and Embedding (OLE) Property Set Data Structures Intellectual Property Rights Notice for Open Specifications Documentation Technical Documentation. Microsoft publishes Open Specifications

More information

Distributed Systems 8. Remote Procedure Calls

Distributed Systems 8. Remote Procedure Calls Distributed Systems 8. Remote Procedure Calls Paul Krzyzanowski pxk@cs.rutgers.edu 10/1/2012 1 Problems with the sockets API The sockets interface forces a read/write mechanism Programming is often easier

More information

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab.

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab. University of Technology Laser & Optoelectronics Engineering Department C++ Lab. Second week Variables Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable.

More information

[MS-OLEPS]: Object Linking and Embedding (OLE) Property Set Data Structures

[MS-OLEPS]: Object Linking and Embedding (OLE) Property Set Data Structures [MS-OLEPS]: Object Linking and Embedding (OLE) Property Set Data Structures The OLE Property Set Data Structures are a generic persistence format for sets of properties typically used to associate simple

More information

C Program Development and Debugging under Unix SEEM 3460

C Program Development and Debugging under Unix SEEM 3460 C Program Development and Debugging under Unix SEEM 3460 1 C Basic Elements SEEM 3460 2 C - Basic Types Type (32 bit) Smallest Value Largest Value short int -32,768(-2 15 ) 32,767(2 15-1) unsigned short

More information

Introduction to Programming

Introduction to Programming Introduction to Programming session 6 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Spring 2011 These slides are created using Deitel s slides Sharif University of Technology Outlines

More information

MsSQL Library SL for CODESYS V3.5

MsSQL Library SL for CODESYS V3.5 MsSQL Library SL for CODESYS V3.5 User guide V1.2.0.0 www.plc2sql.com mail: support@plc2sql.com Last revision: March 2017 c by PLC2SQL 2017 Copyright All rights reserved Contents 1 Product description

More information

Programming in C. What is C?... What is C?

Programming in C. What is C?... What is C? C Programming in C UVic SEng 265 Developed by Brian Kernighan and Dennis Ritchie of Bell Labs Earlier, in 1969, Ritchie and Thompson developed the Unix operating system We will be focusing on a version

More information

Programming in C UVic SEng 265

Programming in C UVic SEng 265 Programming in C UVic SEng 265 Daniel M. German Department of Computer Science University of Victoria 1 SEng 265 dmgerman@uvic.ca C Developed by Brian Kernighan and Dennis Ritchie of Bell Labs Earlier,

More information

Chapter 15 - C++ As A "Better C"

Chapter 15 - C++ As A Better C Chapter 15 - C++ As A "Better C" Outline 15.1 Introduction 15.2 C++ 15.3 A Simple Program: Adding Two Integers 15.4 C++ Standard Library 15.5 Header Files 15.6 Inline Functions 15.7 References and Reference

More information

Creating a C++ Program

Creating a C++ Program Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer. 1 Creating a C++ Program created using an

More information

Programming in C. What is C?... What is C?

Programming in C. What is C?... What is C? Programming in C UVic SEng 265 C Developed by Brian Kernighan and Dennis Ritchie of Bell Labs Earlier, in 1969, Ritchie and Thompson developed the Unix operating system We will be focusing on a version

More information

SDK White Paper. Occlusion Query Checking for Hidden Pixels

SDK White Paper. Occlusion Query Checking for Hidden Pixels SDK White Paper Occlusion Query Checking for Hidden Pixels WP-01402-001_v01 July 2004 Abstract Occlusion Queries Many graphics engines today waste time by attempting to draw pixels of objects that do not

More information

Non-numeric types, boolean types, arithmetic. operators. Comp Sci 1570 Introduction to C++ Non-numeric types. const. Reserved words.

Non-numeric types, boolean types, arithmetic. operators. Comp Sci 1570 Introduction to C++ Non-numeric types. const. Reserved words. , ean, arithmetic s s on acters Comp Sci 1570 Introduction to C++ Outline s s on acters 1 2 3 4 s s on acters Outline s s on acters 1 2 3 4 s s on acters ASCII s s on acters ASCII s s on acters Type: acter

More information

Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts

Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by Walter

More information

CA ERwin Data Modeler. API Reference Guide

CA ERwin Data Modeler. API Reference Guide CA ERwin Data Modeler API Reference Guide r8 This documentation, which includes embedded help systems and electronically distributed materials, (hereinafter referred to as the Documentation ) is for your

More information

Client and Server (DirectX)

Client and Server (DirectX) Client and Server (DirectX) Vishnu Kotrajaras Server scalability Your game can handle more players at a time (Over internet, most peer-topeer can only handle about 6 players) All depend on server power

More information

Week 9. Muhao Chen

Week 9. Muhao Chen Week 9 Muhao Chen muhaochen@ucla.edu http://yellowstone.cs.ucla.edu/~muhao/ 1 Outline Class Final Practice 2 Class class vending_machine { public: int get_num() const; //accessor double get_price() const;

More information

Copyright 2008 CS655 System Modeling and Analysis. Korea Advanced Institute of Science and Technology

Copyright 2008 CS655 System Modeling and Analysis. Korea Advanced Institute of Science and Technology The Spin Model Checker : Part I Copyright 2008 CS655 System Korea Advanced Institute of Science and Technology System Spec. In Promela Req. Spec. In LTL Overview of the Spin Architecture Spin Model pan.c

More information

Types, Variables, and Constants

Types, Variables, and Constants , Variables, and Constants What is a Type The space in which a value is defined Space All possible allowed values All defined operations Integer Space whole numbers +, -, x No divide 2 tj Why Types No

More information

Understanding the DLCALL Function

Understanding the DLCALL Function Understanding the DLCALL Function R:BASE Technologies, Inc. Understanding the DLCALL Function by R:BASE Technologies, Inc. Special thanks to: Mike Byerley (Fort Wayne, Indiana), an Authorized R:BASE Developer,

More information

EVB - PSF - MLX90640 Product Specific Function description Software Library

EVB - PSF - MLX90640 Product Specific Function description Software Library Contents CONTENTS... 1 1 INTRODUCTION... 3 2 SOFTWARE STRUCTURE... 3 2.1 Object Model... 3 2.2 Objects with Interfaces... 4 3 PSF090640EVMLXMANAGER OBJECT... 5 3.1 Background... 5 4 PSF090640EVMLXDEVICE

More information

C: How to Program. Week /Mar/05

C: How to Program. Week /Mar/05 1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers

More information

C#: framework overview and in-the-small features

C#: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer C#: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer

More information

Fundamentals of Programming

Fundamentals of Programming Fundamentals of Programming Lecture 3 - Constants, Variables, Data Types, And Operations Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline C Program Data types Variables

More information