Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Cannot create DSN name

Cannot create DSN name

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
9 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    raju_shiva
    wrote on last edited by
    #1

    Hi sir, I want to create a DSN Name and set a path for that. I am using "SQLConfigDataSource" function for this. It is not giving any error and running properly.But it is not writing to DNS. Here ia wat i am doing

    SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));

    Am i doing right???or any other stuff need to be done. Thanks Raj

    C 1 Reply Last reply
    0
    • R raju_shiva

      Hi sir, I want to create a DSN Name and set a path for that. I am using "SQLConfigDataSource" function for this. It is not giving any error and running properly.But it is not writing to DNS. Here ia wat i am doing

      SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));

      Am i doing right???or any other stuff need to be done. Thanks Raj

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      Did you check the return value? :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      R 1 Reply Last reply
      0
      • C CPallini

        Did you check the return value? :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        R Offline
        R Offline
        raju_shiva
        wrote on last edited by
        #3

        Hi, I tried with this

        bool aDSNCreated = false;
        aDSNCreated = SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));
        printf("%d",aDSNCreated );

        aDSNCreated value is zero. what i am doing wrong?? Thanks Raj

        C 1 Reply Last reply
        0
        • R raju_shiva

          Hi, I tried with this

          bool aDSNCreated = false;
          aDSNCreated = SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));
          printf("%d",aDSNCreated );

          aDSNCreated value is zero. what i am doing wrong?? Thanks Raj

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          From MSDN[^]:

          When SQLConfigDataSource returns FALSE, an associated *pfErrorCode value can be obtained by calling SQLInstallerError. The following table lists the *pfErrorCode values that can be returned by SQLInstallerError and explains each one in the context of this function.

          :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          R 1 Reply Last reply
          0
          • C CPallini

            From MSDN[^]:

            When SQLConfigDataSource returns FALSE, an associated *pfErrorCode value can be obtained by calling SQLInstallerError. The following table lists the *pfErrorCode values that can be returned by SQLInstallerError and explains each one in the context of this function.

            :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            R Offline
            R Offline
            raju_shiva
            wrote on last edited by
            #5

            Hi sir.

            CPallini wrote:

            an associated *pfErrorCode value can be obtained by calling SQLInstallerError

            I am not getting how to get the errorcode.I am trying as below

            bool aDSNCreated = false;
            //char *str;// = "asdasdsd\0";
            RETCODE retcode= SQL_SUCCESS;
            aDSNCreated = SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));
            printf("%d",aDSNCreated );
            if(aDSNCreated == false)
            {
            retcode = SQLInstallerError(2, NULL,NULL,100,NULL);

            }

            I am not getting wat paramaters to send and return the error code.. please help me out. Sorry i know its a very silly question. Thanks Raj

            C 1 Reply Last reply
            0
            • R raju_shiva

              Hi sir.

              CPallini wrote:

              an associated *pfErrorCode value can be obtained by calling SQLInstallerError

              I am not getting how to get the errorcode.I am trying as below

              bool aDSNCreated = false;
              //char *str;// = "asdasdsd\0";
              RETCODE retcode= SQL_SUCCESS;
              aDSNCreated = SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));
              printf("%d",aDSNCreated );
              if(aDSNCreated == false)
              {
              retcode = SQLInstallerError(2, NULL,NULL,100,NULL);

              }

              I am not getting wat paramaters to send and return the error code.. please help me out. Sorry i know its a very silly question. Thanks Raj

              C Offline
              C Offline
              CPallini
              wrote on last edited by
              #6

              I would do:

              BOOL isDSNCreated;
              isDSNCreated = SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));
              if (isDSNCreated == FALSE)
              {
              CHAR szError[SQL_MAX_MESSAGE_LENGTH];
              DWORD dwError;
              WORD cbError;
              RETCODE retcode;
              retcode = SQLInstallerError(1, &dwError, szError, SQL_MAX_MESSAGE_LENGTH-1, &cbError);
              // check 'retcode', have a look at 'dwError', show 'szError', whatever...
              }

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              R 1 Reply Last reply
              0
              • C CPallini

                I would do:

                BOOL isDSNCreated;
                isDSNCreated = SQLConfigDataSource(NULL, ODBC_ADD_SYS_DSN, _T("Microsoft Access Driver (*.mdb)\0"), _T("DSN=SAMPLEE\0DBQ=D:\\SAMPLE.mdb\0"));
                if (isDSNCreated == FALSE)
                {
                CHAR szError[SQL_MAX_MESSAGE_LENGTH];
                DWORD dwError;
                WORD cbError;
                RETCODE retcode;
                retcode = SQLInstallerError(1, &dwError, szError, SQL_MAX_MESSAGE_LENGTH-1, &cbError);
                // check 'retcode', have a look at 'dwError', show 'szError', whatever...
                }

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                R Offline
                R Offline
                raju_shiva
                wrote on last edited by
                #7

                CPallini wrote:

                retcode = SQLInstallerError(1, &dwError, szError, SQL_MAX_MESSAGE_LENGTH-1, &cbError);

                Hi sir, I am getting this error:

                Error 47 error C2664: 'SQLInstallerErrorW' : cannot convert parameter 3 from 'CHAR [512]' to 'LPWSTR'

                Thanks Raj

                C 1 Reply Last reply
                0
                • R raju_shiva

                  CPallini wrote:

                  retcode = SQLInstallerError(1, &dwError, szError, SQL_MAX_MESSAGE_LENGTH-1, &cbError);

                  Hi sir, I am getting this error:

                  Error 47 error C2664: 'SQLInstallerErrorW' : cannot convert parameter 3 from 'CHAR [512]' to 'LPWSTR'

                  Thanks Raj

                  C Offline
                  C Offline
                  CPallini
                  wrote on last edited by
                  #8

                  The use:

                  TCHAR szError[SQL_MAX_MESSAGE_LENGTH];
                  DWORD dwError;
                  WORD cbError;
                  RETCODE retcode;
                  retcode = SQLInstallerError(1, &dwError, szError, SQL_MAX_MESSAGE_LENGTH-1, &cbError);

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                  [My articles]

                  R 1 Reply Last reply
                  0
                  • C CPallini

                    The use:

                    TCHAR szError[SQL_MAX_MESSAGE_LENGTH];
                    DWORD dwError;
                    WORD cbError;
                    RETCODE retcode;
                    retcode = SQLInstallerError(1, &dwError, szError, SQL_MAX_MESSAGE_LENGTH-1, &cbError);

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                    [My articles]

                    R Offline
                    R Offline
                    raju_shiva
                    wrote on last edited by
                    #9

                    Hi sir, Thank you.Its building without error. I am getting the retcode as zero(i.e SQL_SUCCESS). But i am not finding the DSN Created when i am checking through Control Panel->ODBC Thanks Raj

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups