Results 1 to 2 of 2

Thread: System DSN

  1. #1
    busbyw Guest

    Angry System DSN

    Has anyone on this site managed to successfully install and configure a SQL Server System DSN?

    I have managed to configure a new DSN with Server name, ANSI padding, DataBase name, etc. etc. I can also get it to use NT or SQL security.

    My problem is I want to specify a username and password for the SQL trusted security. I have looked everywhere for DSN security properties, and found nothing, I've even tried the UID/PWD combination specified in C/C++ libraries, but all I get is an error.

    I did manage to hack the username part of the DSN by adding in the 'LastUser' regsitry setting to the ODBC.ini key, but I would like to state that it is a hack and I would love to do this correctly, using the correct property names.

    Help.

  2. #2
    Join Date
    Oct 2001
    Location
    Columbus, OH
    Posts
    153
    busbyw,

    I have done this successfully. Hope this helps.

    Marie

    Here is my code
    (NOTE: USICOAL = DATABASE NAME):

    Disable(LOGGING);
    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
    nResult = RegDBKeyExist ("\\SOFTWARE\\ODBC\\ODBC.INI\\USICOAL");
    szClass = "";
    nvType = REGDB_STRING;

    if(nResult < 1) then //DOES NOT EXIST..
    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
    RegDBCreateKeyEx ( "\\SOFTWARE\\ODBC\\ODBC.INI\\
    USICOAL", szClass );
    endif;

    svValue = "USICOAL";
    szDatabaseName = svValue;
    svName = "Database";
    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
    RegDBSetKeyValueEx ( "\\SOFTWARE\\ODBC\\ODBC.INI\\USICOAL", svName, nvType, svValue, nvSize );

    //set the odbc driver
    svValue = SystemFolder ^ "sqlsrv32.dll";
    svName = "Driver";
    Disable(LOGGING);
    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
    RegDBSetKeyValueEx( "\\SOFTWARE\\ODBC\\ODBC.INI\\USICOAL", svName, nvType, svValue, nvSize );

    svValue = "Admin";
    svName = "LastUser";

    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
    RegDBSetKeyValueEx( "\\SOFTWARE\\ODBC\\ODBC.INI\\USICOAL", svName, nvType, svValue, nvSize );

    svValue = szMYSERVERNAME;
    svName = "Server";
    Disable(LOGGING);
    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
    RegDBSetKeyValueEx( "\\SOFTWARE\\ODBC\\ODBC.INI\\USICOAL", svName, nvType, svValue, nvSize );

    //szKey = "\\SOFTWARE\\ODBC\\ODBC.INI\\ODBC Data Sources";
    nvType = REGDB_STRING;
    svName = "USICOAL" ;
    svValue = "SQL Server";

    RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
    RegDBSetKeyValueEx( "\\SOFTWARE\\ODBC\\ODBC.INI\\ODBC Data Sources", svName, nvType, svValue, nvSize );
    Marie Tupps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •