Subject Re: [ib-support] gpre and VisualC++
Author C R Zamana
Paul Schmidt wrote:

>
> I can see this is going to be a easy and simple process, now gpre
> doesn't work: First of all it seems that it needs to know the exact
> database path, username and password in order to be able to compile.
>
> So I fed it the line (this is really all on one line)
>
> "c:\program files\firebird\bin\gpre" $(InputPath) -d
> lnxsrvr:/var/ib_data/mystuff.gdb -user sysdba -password masterkey
>
> It promptly told me that the user is not defined, yeah right, either
> I have something wrong here, or gpre is nuts. Please tell me it's
> something I have wrong, and kindly tell me gpre (Firebird 0.9.4.41)
> is really OK.
>
> More Questions:
>
> 1) I want to give the client enough flexability that he can call the
> database whatever he wants, and stick it wherever he wants, and use a
> different user and password, I wouldn't normally use SYSDBA, but I
> want to experiment with this....
>
> 2) Even if I use the above, can I still specify something else with a
> connect statement inside.
>

I use gpre in Linux without problems. See if my example can
help you about the connection stuff:

---------------------------------------------------------------------------------
#include "ibase.h"
#include "align.h"

#define ISC_INT64_FORMAT "ll"

extern FILE *fp;

XSQLDA *_SQLDA[MAX_CURSOR];
XSQLDA *sqlda;

EXEC SQL SET SQL DIALECT 1;
EXEC SQL SET DATABASE db1 = COMPILETIME
"/opt/interbase/examples/employee.gdb";

EXEC SQL BEGIN DECLARE SECTION;
char connid[DATABASE_NAME_SIZE];
char stmt_buf[RECORD_SIZE];
EXEC SQL END DECLARE SECTION;


/*
* Conexao
*/
void sql_connect( STR_CONN *conn ) {

EXEC SQL BEGIN DECLARE SECTION;
char username[USERNAME_NAME_SIZE];
char password[PASSWORD_NAME_SIZE];
char dbname[DATABASE_NAME_SIZE];
unsigned int connid;
EXEC SQL END DECLARE SECTION;


strcpy( username, conn->username );
strcpy( password, conn->password );
strcpy( dbname, conn->dbname );
connid = conn->connid;

EXEC SQL
CONNECT :dbname AS db1
USER :username
PASSWORD :password;

conn->status = SQLCODE;
if ( SQLCODE != 0 ) {
printmsg( "Connection failed" );
}

}

(...)


--
---------------------------------------------------------------------------
zamana@... | "For a list of the ways which technology has
zamana@... | failed to improve our quality of life, press 3"
http://www.inso.com.br | Phil Reed, on Slashdot
---------------------------------------------------------------------------