Pro C C++ Login denied as the variable isnt stored

From: Rashyid <rra_at_excite.com>
Date: 18 Aug 2001 03:42:00 -0700
Message-ID: <79c1319c.0108180241.6f433221_at_posting.google.com>


Hi there all,

I have a problem with my Pro C program, as i cant log on.. The thing is, the code precompiles and compiles nicely without any errors, but when i run it, i get the error message

oracle error --

ORA 01005: NULL password given; login denied

and then when i changed my code to print out the username, password, and dbstring variables, heres what i get:

USERNAMEvgnnt4
PASSWORD
DBSTRINGcmpsnt4.world

as you can see there is no value inserted into the password variable. This is so very very very strange as in my code, all these three are declared and assigned a value the very same way.(The code is attached below). I am at a loss here as i dont know whats wrong where. Actually, when i change the names of the variables, either one of the other two would give a NULL! This is WEIRD!!! I have no idea whether its a pro c / or a MS VC++ error??!! anyboday can help me here?

Thanks in advance

Rashyid Redza

Attached code....

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sqlda.h>
#include <sqlcpr.h>
#include <sqlca.h>
#include <string.h>

VARCHAR uname[40];
VARCHAR pword[40];
VARCHAR db_string [40];
VARCHAR next_id [8];
VARCHAR table_name [20];

void sql_error(msg)

    char *msg;
{

    char err_msg[128];
    size_t buf_len, msg_len;

    EXEC SQL WHENEVER SQLERROR CONTINUE;     printf("\n%s\n", msg);
    buf_len = sizeof (err_msg);
    sqlglm(err_msg, &buf_len, &msg_len);     printf("%.*s\n", msg_len, err_msg);

    EXEC SQL ROLLBACK RELEASE;
    exit(EXIT_FAILURE);
}

void main ()

{         

	strncpy ((char*) uname.arr, "vgnnt4", 40);
	uname.len=(unsigned short) strlen((char*) uname.arr);
	
	strncpy ((char*) db_string.arr, "cmpsnt4.world", 40);
	db_string.len=(unsigned short) strlen((char*) db_string.arr);
	
	strncpy ((char*) pword.arr, "vgnnt42", 40);
	pword.len=(unsigned short) strlen((char*) pword.arr);

	strncpy ((char*) table_name.arr, "content_aggregated", 40);
	table_name.len=(unsigned short) strlen((char*) table_name.arr);
	
	printf("USERNAME%s\n", uname.arr);
	printf("PASSWORD%s\n", pword.arr);
	printf("DBSTRING%s\n", db_string.arr);
	
	EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error--\n");
	
	EXEC SQL CONNECT :uname IDENTIFIED BY :pword USING :db_string;
	
	printf("\n Connected to Oracle as user: %s\n", uname.arr);


.... and the code goes on and on... dont think the rest is relevant.. Received on Sat Aug 18 2001 - 12:42:00 CEST

Original text of this message