On Nov 11, 2:38 pm, Erland Sommarskog <esq...@sommarskog.sewrote:
One option is used managed C++ and .Net. That would permit you to use
SqlClient from ADO .Net, which I think is a very good API.
If you want to work with native code, you two have options ODBC and OLE DB.
I will try ADO.net, but that is probably going to take a bit more
learning... I have never used either .net, or managed C++ before. But
though I forgot to say this in my original post, I am hoping to figure
out how to use ADO (not .net) for now.
I've included "msado25.h", which gives access to the _Connection and
_Recordset objects. And, I've found numerous examples for using it
from VB on the web which I have attempted to translate into C++, such
as:
CString csServer = _T("TestServer");
CString csDatabase = _T("TestDatabase");
CString csSQLConnectString;
csSQLConnectString.Format(_T("Provider=MSDATASHAPE ;Data
Provider=SQLOLEDB;")
_T("server=%s;Database=%s;Integrated Security='SSPI';"),
m_csServer, m_csDatabase);
CString csQuery = _T("SELECT * FROM Employees");
VARIANT vSQLVariant;
_Connection sqlConnection;
_Recordset sqlRecordset;
// In VB it would be:
// sqlConnection.Open AccessConnect
// Set sqlRecordset = sqlConnection.Execute("SELECT * FROM
Employees")
sqlConnection.Open(csSQLConnectString,_T(""),_T("" ),0);
sqlRecordset = sqlConnection.Execute(csSQLConnectString,
&vSQLVariant, 0);
However, this doesn't work... Obviously I'm not using the connection
and recordset objects right, but I can't find any documentation on
them.
Any advice?
Thanks in advance.