Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found a good example for the first part of my question on <a href="http://www.codeproject.com/KB/database/ODBCMngr.aspx" rel="nofollow noreferrer">this website</a>.</p> <p>As for the second part, "how to configure the DSN", I found another <a href="https://stackoverflow.com/questions/334939/how-do-i-create-an-odbc-dsn-entry-using-c">code snippet</a> which only needed some tweaking. </p> <pre><code> private const string ODBC_INI_REG_PATH = "SOFTWARE\\ODBC\\ODBC.INI\\"; private const string ODBCINST_INI_REG_PATH = "SOFTWARE\\ODBC\\ODBCINST.INI\\"; /// &lt;summary&gt; /// Creates a new System-DSN entry with the specified values. If the DSN exists, the values are updated. /// &lt;/summary&gt; /// &lt;param name="dsnName"&gt;Name of the DSN for use by client applications&lt;/param&gt; /// &lt;param name="description"&gt;Description of the DSN that appears in the ODBC control panel applet&lt;/param&gt; /// &lt;param name="server"&gt;Network name or IP address of database server&lt;/param&gt; /// &lt;param name="driverName"&gt;Name of the driver to use&lt;/param&gt; /// &lt;param name="trustedConnection"&gt;True to use NT authentication, false to require applications to supply username/password in the connection string&lt;/param&gt; /// &lt;param name="database"&gt;Name of the datbase to connect to&lt;/param&gt; public static void CreateDSN2(string dsnName, string description, string server, string driverName, bool trustedConnection, string database, string user, string password, string port) { // Lookup driver path from driver name var driverKey = Registry.LocalMachine.CreateSubKey(ODBCINST_INI_REG_PATH + driverName); if (driverKey == null) throw new Exception(string.Format("ODBC Registry key for driver '{0}' does not exist", driverName)); string driverPath = driverKey.GetValue("Driver").ToString(); // Add value to odbc data sources var datasourcesKey = Registry.LocalMachine.CreateSubKey(ODBC_INI_REG_PATH + "ODBC Data Sources"); if (datasourcesKey == null) throw new Exception("ODBC Registry key for datasources does not exist"); datasourcesKey.SetValue(dsnName, driverName); // Create new key in odbc.ini with dsn name and add values var dsnKey = Registry.LocalMachine.CreateSubKey(ODBC_INI_REG_PATH + dsnName); //MessageBox.Show(dsnKey.ToString()); if (dsnKey == null) throw new Exception("ODBC Registry key for DSN was not created"); dsnKey.SetValue("Data Source", dsnName); dsnKey.SetValue("Database", database); dsnKey.SetValue("Description", description); dsnKey.SetValue("Driver", driverPath); dsnKey.SetValue("Server", server); dsnKey.SetValue("User name", user); dsnKey.SetValue("Password", password); dsnKey.SetValue("Port", port); dsnKey.SetValue("Trusted_Connection", trustedConnection ? "Yes" : "No"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload