Pradeep Yadav

Pradeep Yadav

  • 322
  • 5.6k
  • 2.7m

Create DSN using C#

May 6 2019 8:16 AM
Hi Team,
 
I am creting DSN for Hive driver using C#, we are able to create using below code
  1. var driverKey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(ODBCINST_INI_REG_PATH + driverName);  
  2. if (driverKey == nullthrow new Exception(string.Format("ODBC Registry key for driver '{0}' does not exist", driverName));  
  3. string driverPath = driverKey.GetValue("Driver").ToString();  
  4. var datasourcesKey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(ODBC_INI_REG_PATH + "ODBC Data Sources");  
  5. if (datasourcesKey == nullthrow new Exception("ODBC Registry key for datasources does not exist");  
  6. datasourcesKey.SetValue(dsnName, driverName);  
  7. var dsnKey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(ODBC_INI_REG_PATH + dsnName);  
  8. if (dsnKey == nullthrow new Exception("ODBC Registry key for DSN was not created");  
  9. dsnKey.SetValue("Database", database);  
  10. dsnKey.SetValue("Description", description);  
  11. dsnKey.SetValue("Driver", driverPath);  
  12. dsnKey.SetValue("LastUser", Environment.UserName);  
  13. dsnKey.SetValue("Server", server);  
  14. dsnKey.SetValue("Database", database);  
  15. dsnKey.SetValue("AuthMech""3");  
  16. dsnKey.SetValue("UID""mapr");  
  17. dsnKey.SetValue("PWD""mapr");  
However I want to set server side properties available in Advance options button by adding key and value. 
 
I tried using below code 
  1. dsnKey.SetValue("hive.vectorized.execution.enabled""1");  
  2. dsnKey.SetValue("hive.vectorized.execution.reduce.enabled""1");
However, it is not working. 
 
Please help  me for the same

Answers (2)