Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy can't I get my CDatabase object to understand my Data Source Name?
    primarykey
    data
    text
    <p>I'm using the MFC class CDatabase. To establish a connection to SQL Server, I'm calling OpenEx() with a connection string. My problem is that the object seems unable to interpret the DSN part of the string. The connection string looks like this:</p> <pre><code> ODBC;DSN=mySystemDSN;UID=myUsername;WSID=myMachineName;DATABASE=myDatabaseName;Trusted_Connection=Yes </code></pre> <p>That ought to be right because I got it by using OpenEx( NULL ), choosing the data source manually and then calling GetConnect().</p> <p>But this string doesn't seem to contain enough information: OpenEx() always pops up a dialogue asking for more. It doesn't seem to matter what I choose from this dialogue - I can pick a DSN associated with a completely different database and things still work (a call to GetConnect() in that situation shows that it's using my connection string except for the DSN part, which is borrowed from the other data source).</p> <p>I need my application to be able to connect to the database automatically - dialogue boxes are a deal-breaker. I've tried a DSN-less connection with similar results. What's going on here, and what can I do about it?</p> <p><em>edit in answer to Neil Butterworth's question:</em></p> <p>The information I provided when I created the DSN in the ODBC Data Source Administrator was as follows:</p> <p>driver: SQL Server<br> name: mySystemDSN<br> server: myMachineName<br> authentication type (can be Windows or SQL Server): Windows<br> checkbox "Connect to SQL Server to obtain default settings for the additional configuration options.": ticked<br> checkbox "Change the default database to": ticked and myDatabaseName chosen from drop-down menu<br> checkbox "Use ANSI quoted identifiers": ticked<br> checkbox "Use ANSI nulls, paddings and warnings": ticked<br> checkbox "Perform translation for character data": ticked</p>
    singulars
    1. This table or related slice is empty.
    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. 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