Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Posts
    70

    Unanswered: trying to change a sybase password with sybdb.h in C

    Heres my code pretty much:


    id, password, server, and db are all set properly and have the correct strings.
    Code:
    char CharBuffer[1024];
    DBPROCESS *dbProc;
    LOGINREC  *login;
    RETCODE rc;
    login = dblogin();
    DBSETLUSER(login, id);
    DBSETLPWD(login, password);
    DBSETLAPP(login, "pwdgen");
    dbProc = dbopen(login, server);
    dbuse(dbProc, db);
    if(dbProc == NULL)
    	//log some failure and quit
    else
    	//it worked
    
    sprintf(CharBuffer, "%s", "sp_password \"OldPassword\", \"NewPassword\"");
    
    dbcmd(dbProc, CharBuffer);
    rc = dbsqlexec(dbProc);
    
    if(rc != SUCCEED) {
    	//it failed log it
    	return 1;
    }
    
    while(rc = dbresults(dbProc) != NO_MORE_RESULTS ) {
    	if(rc != SUCCEED) {
    		//it failed log it
    		return 1;
    	}
    
    }
    Before I didnt have the initial if statement checking the return code. If I didnt have that it would go right by the while loop with no error even though the sp_password command isnt working. The password isnt changed, I can still log in with the old one.
    Is there a way to get some type of detailed error back from that dbresults and/or dbsqlexec?

    If anyone could give me some pointers I would appreciate it.

  2. #2
    Join Date
    Jan 2004
    Posts
    70
    Well I guess I sort of have the problem fixed.

    for the text of "NewPassword" I was passing the string "test"

    I guess that was too short. I tried "test1234" and it ran fine. I left the first rc != success in there.

    is there just no way to tell why it failed? Just that it did fail?

Posting Permissions

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