SQLCODE -1024

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gerd

    SQLCODE -1024

    Hi all,

    I'm doing my very first steps with DB2 programming, so please forgive
    me my stupid question.

    I try a very simple first db-access using embedded sql with plain
    C-code (MS-VC++ on windows). I did a simple

    EXEC SQL SELECT COUNT (*)
    INTO :CNT
    FROM TESTTAB;

    The prep and bind on db2 has no errors, the C-code compiles and links
    errorfree, too.

    When running the program, I get a code -1024 (not connected?). What
    have I to do to run the code? I tried a db2logon in the command
    window first, but this did not help.

    Please help me.

    Regards,
    Gerd

  • Gerd

    #2
    Re: SQLCODE -1024

    PS: I've got a hint, that I have to set some Windows environment
    variables first. Is this correct? And if, which variables , which
    values?

    Gerd schrieb:
    [color=blue]
    > Hi all,
    >
    > I'm doing my very first steps with DB2 programming, so please forgive
    > me my stupid question.
    >
    > I try a very simple first db-access using embedded sql with plain
    > C-code (MS-VC++ on windows). I did a simple
    >
    > EXEC SQL SELECT COUNT (*)
    > INTO :CNT
    > FROM TESTTAB;
    >
    > The prep and bind on db2 has no errors, the C-code compiles and links
    > errorfree, too.
    >
    > When running the program, I get a code -1024 (not connected?). What
    > have I to do to run the code? I tried a db2logon in the command
    > window first, but this did not help.
    >
    > Please help me.
    >
    > Regards,
    > Gerd[/color]

    Comment

    • Brian Tkatch

      #3
      Re: SQLCODE -1024

      Do you have DB2 Connect installed? Do you have an alias setup to
      connect to the database? Did you use the configuration client to "test"
      the connection? Was the test succesful?

      Connecting to a DB2 database takes a few pieces of information to
      identify it, and a DB2 client to do the connection itself. The
      information is input once, and assigned an alias. Then, a connect
      statement is used with the alias to connect.

      B.

      Comment

      • Gerd

        #4
        Re: SQLCODE -1024

        Yes, DB2 is installed. My alias is created as TESTDB. I can connect
        successfully via command editor and I can successfully submit select
        statements. If I add an explicit connect to my code (EXEC SQL CONNECT
        TO TESTDB ... ;) then it works. But if I do not explizitly connect but
        try an implizit connect it does not work.
        I've got an answer stating that I would have to declare some
        environment variables (DB2DBDFT, DB2USER, DB2PASSWORD), but when doing
        this I get an other error (see my other thread).

        Comment

        • Brian Tkatch

          #5
          Re: SQLCODE -1024

          OK, i see, i was just making sure you had the basics covered, and you
          seem to have done that pretty well. :)

          B.

          Comment

          • Ian

            #6
            Re: SQLCODE -1024

            Gerd wrote:[color=blue]
            > PS: I've got a hint, that I have to set some Windows environment
            > variables first. Is this correct? And if, which variables , which
            > values?[/color]

            Are you actually connecting to your database in your application?

            EXEC SQL CONNECT TO TESTDB USER :U USING :P;

            Comment

            • Gerd

              #7
              Re: SQLCODE -1024

              No I'm not explicitly connecting from my application. The dokumentation
              says, that declaring the environment variables DB2DBDFT, DB2USER and
              DB2PASSWORD results in automatic connect. But when I declare this
              variables, I get sqlcode -30082 "Password missing". So now I'm looking
              how to specify the password correctly.

              Comment

              • Gert van der Kooij

                #8
                Re: SQLCODE -1024

                In article <1143620883.845 705.138480@i39g 2000cwa.googleg roups.com>,
                GerdM.O@t-online.de says...[color=blue]
                > No I'm not explicitly connecting from my application. The dokumentation
                > says, that declaring the environment variables DB2DBDFT, DB2USER and
                > DB2PASSWORD results in automatic connect. But when I declare this
                > variables, I get sqlcode -30082 "Password missing". So now I'm looking
                > how to specify the password correctly.
                >
                >[/color]

                AFAIK DB2PASWORD is not some default variable used by DB2. Could it be
                that it's used by the development tool you use when running your program
                from the tool to automatically create a connection?

                Comment

                • Gerd

                  #9
                  Re: SQLCODE -1024

                  I think not, because I've checked this information, and found it in
                  some redbooks:
                  CONNECT TO database: If both the userid and the password are missing in
                  the
                  connect statement, they are extracted from the DB2USERID and
                  DB2PASSWORD
                  environment variables.

                  Comment

                  • Gert van der Kooij

                    #10
                    Re: SQLCODE -1024

                    In article <1143631576.784 798.24110@u72g2 000cwu.googlegr oups.com>,
                    GerdM.O@t-online.de says...[color=blue]
                    > I think not, because I've checked this information, and found it in
                    > some redbooks:
                    > CONNECT TO database: If both the userid and the password are missing in
                    > the
                    > connect statement, they are extracted from the DB2USERID and
                    > DB2PASSWORD
                    > environment variables.
                    >
                    >[/color]

                    In which redbook did you find that one? When searching the online docs
                    this environment variable can't be found.

                    Comment

                    • Gert van der Kooij

                      #11
                      Re: SQLCODE -1024

                      In article <MPG.1e94c0adcb 2acbd39896e8@ne ws.xs4all.nl>,
                      nomail@nl.invalid says...[color=blue]
                      > In article <1143631576.784 798.24110@u72g2 000cwu.googlegr oups.com>,
                      > GerdM.O@t-online.de says...[color=green]
                      > > I think not, because I've checked this information, and found it in
                      > > some redbooks:
                      > > CONNECT TO database: If both the userid and the password are missing in
                      > > the
                      > > connect statement, they are extracted from the DB2USERID and
                      > > DB2PASSWORD
                      > > environment variables.
                      > >
                      > >[/color]
                      >
                      > In which redbook did you find that one? When searching the online docs
                      > this environment variable can't be found.
                      >[/color]

                      I've found one reference to DB2USER and DB2PASSWORD within a VisualAge
                      redbook which mentions it's usage in implicit connections. I didn't find
                      any other reference to it in the DB2 docs so I don't think you can use
                      them automatically using a implicit connect when running your C program.

                      Comment

                      Working...