By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,756 Members | 1,760 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,756 IT Pros & Developers. It's quick & easy.

SQLCODE -1024

P: n/a
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

Mar 28 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
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:
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


Mar 28 '06 #2

P: n/a
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.

Mar 28 '06 #3

P: n/a
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).

Mar 28 '06 #4

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

B.

Mar 28 '06 #5

P: n/a
Ian
Gerd wrote:
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?


Are you actually connecting to your database in your application?

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

Mar 29 '06 #6

P: n/a
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.

Mar 29 '06 #7

P: n/a
In article <11**********************@i39g2000cwa.googlegroups .com>,
Ge*****@t-online.de says...
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.


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?

Mar 29 '06 #8

P: n/a
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.

Mar 29 '06 #9

P: n/a
In article <11*********************@u72g2000cwu.googlegroups. com>,
Ge*****@t-online.de says...
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.


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

P: n/a
In article <MP************************@news.xs4all.nl>,
no****@nl.invalid says...
In article <11*********************@u72g2000cwu.googlegroups. com>,
Ge*****@t-online.de says...
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.


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


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.
Mar 29 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.