I need to create 32 bit System DSN programitically in Windows 7 OS which is 64 bit. I used the following code.
[DllImport("ODBCCP32.DLL", CharSet = CharSet.Unicode, SetLastError = true)]
private static extern bool SQLConfigDataSource(UInt32 hwndParent, RequestFlags fRequest,string lpszDriver, string lpszAttributes);
public static void CreateDSN()
{
string strDrivername = "SQL Server";
string strConfig = "DSN=test6\0" +
"Database=Test\0" +
"Description=StackOverflow Sample\0" +
"Server=10.10.11.16\0" +
"Trusted_Connection=Yes\0";
bool success = SQLConfigDataSource(0, RequestFlags.ODBC_ADD_SYS_DSN, strDrivername, strConfig);
}
Above code working. but it is creating 64 bit ODBC System DSN. Kindly help me to create 32 bit DSN.
Thanks, Karthik P