Computing.Net > Forums > Programming > C# function to ODBC Drivers,WinXP

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

C# function to ODBC Drivers,WinXP

Reply to Message Icon

Name: SNYP40A1
Date: July 30, 2007 at 15:56:58 Pacific
OS: WInXP
CPU/Ram: P4 / 1 GB
Comment:

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;
}



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: C# function to ODBC Drivers,WinXP

Microsoft ODBC Driver for Oracle www.computing.net/answers/programming/microsoft-odbc-driver-for-oracle/6951.html

So confused about C functions.. www.computing.net/answers/programming/so-confused-about-c-functions/7040.html

calling c functions from java www.computing.net/answers/programming/calling-c-functions-from-java/2913.html