Subject | API vs ISQL problems |
---|---|
Author | edcurren |
Post date | 2005-05-26T19:27:22Z |
Hello everyone,
I am attempting to write an application using FireBird as the back
end database. On a simple INSERT statement I am running into
issues. The relevand code is this:
isc_db_handle hDb = NULL; /* database handle */
isc_tr_handle hTx = NULL; /* transaction handle */
ISC_STATUS status [20];
char dpb_buffer[256], *dpb;
short dpb_length;
dpb = dpb_buffer;
*dpb++ = isc_dpb_version1;
*dpb++ = isc_dpb_num_buffers;
*dpb++ = 1;
*dpb++ = 90;
dpb_length = dpb - dpb_buffer;
dpb = dpb_buffer;
/* Add user name and password to DPB. */
isc_expand_dpb(&dpb, &dpb_length, isc_dpb_user_name,
m_AdminDbUser, isc_dpb_password, m_AdminDbPass, NULL);
if (isc_attach_database(status, 0, (char *)
m_DatabaseFileName.c_str(), &hDb, dpb_length, dpb))
{
GetErrorMessages(status, errors);
return 1;
}
char *stmt = new char[1024];
strcpy(stmt, "INSERT INTO Users (UserName, UserPassword)
VALUES ('");
strcat(stmt, NewUserName.c_str());
strcat(stmt, "', '");
strcat(stmt, NewUserPassword.c_str());
strcat(stmt, "');");
if( isc_dsql_execute_immediate(status, &hDb, &hTx, 0, stmt,
3, NULL) )
{
GetErrorMessages(status, errors);
return 2;
}
When I execute it I receive the following:
Dynamic SQL Error
SQL Error code = -204
Table unknown
USERS
At line 1, column 13.
When I run the same INSERT statement against the same database in
ISQL it works without any errors at all.
Can someone guide me as to what is wrong here?
Thanks all.
I am attempting to write an application using FireBird as the back
end database. On a simple INSERT statement I am running into
issues. The relevand code is this:
isc_db_handle hDb = NULL; /* database handle */
isc_tr_handle hTx = NULL; /* transaction handle */
ISC_STATUS status [20];
char dpb_buffer[256], *dpb;
short dpb_length;
dpb = dpb_buffer;
*dpb++ = isc_dpb_version1;
*dpb++ = isc_dpb_num_buffers;
*dpb++ = 1;
*dpb++ = 90;
dpb_length = dpb - dpb_buffer;
dpb = dpb_buffer;
/* Add user name and password to DPB. */
isc_expand_dpb(&dpb, &dpb_length, isc_dpb_user_name,
m_AdminDbUser, isc_dpb_password, m_AdminDbPass, NULL);
if (isc_attach_database(status, 0, (char *)
m_DatabaseFileName.c_str(), &hDb, dpb_length, dpb))
{
GetErrorMessages(status, errors);
return 1;
}
char *stmt = new char[1024];
strcpy(stmt, "INSERT INTO Users (UserName, UserPassword)
VALUES ('");
strcat(stmt, NewUserName.c_str());
strcat(stmt, "', '");
strcat(stmt, NewUserPassword.c_str());
strcat(stmt, "');");
if( isc_dsql_execute_immediate(status, &hDb, &hTx, 0, stmt,
3, NULL) )
{
GetErrorMessages(status, errors);
return 2;
}
When I execute it I receive the following:
Dynamic SQL Error
SQL Error code = -204
Table unknown
USERS
At line 1, column 13.
When I run the same INSERT statement against the same database in
ISQL it works without any errors at all.
Can someone guide me as to what is wrong here?
Thanks all.