Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I found a C++ function on the Internet which supposedly retrieves the ODBC driver name which matches "Excel" in the case below. I want to use the same function, but to be called inside a C# program instead of a C++ program. Does anyone know how to translate the function below to be run in C#?
CString CReadExcelDlg::GetExcelDriver()
{
char szBuf[2001];
WORD cbBufMax = 2000;
WORD cbBufOut;
char *pszBuf = szBuf;
CString sDriver;// Get the names of the installed drivers ("odbcinst.h" has to be included )
if(!SQLGetInstalledDrivers(szBuf,cbBufMax,& cbBufOut))
return "";// Search for the driver...
do
{
if( strstr( pszBuf, "Excel" ) != 0 )
{
// Found !
sDriver = CString( pszBuf );
break;
}
pszBuf = strchr( pszBuf, '\0' ) + 1;
}
while( pszBuf[1] != '\0' );return sDriver;
}

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |