Subject Re: [firebird-support] Re: Beginner questions: from access to firebird (using vb and odbc driver)
Author Jason Dodson
Actually, that is nothing like what he is using.


Jeff Lynn wrote:
> adriano,
> I has just started using FB only a couple of weeks via C/C++ API, so
> may be I can share some of my learning with you to ease the learning.
> I didn't use VB but I think the concept is similar.
> 1) You have to attach to the database, in C API,
> isc_attach_database(...) will do the trick. Be aware that if you are
> using embedded database, the standard OS specific database file name
> (with full path) is required. If you are using the client/server
> model, then you have to provide "localhost:C:\aPath\dbfilename" or
> "MyServer:C:\aPath\dbfilename".
> 2) By default, FB database use default userId "SYSDBA" and password
> "masterkey", so you have to define a DPB to define the connection
> parameter for userId and password, to be used in the
> isc_expand_dbp(...) api call prior to calling the
> isc_attach_database(...).
> 3) Then you need to start a transaction using the
> isc_start_transaction(...) call.
> 4) Next depends on whether you want to execute a simnple SQL that does
> not required any parameter marker or not. For non parameter marker
> stmt, say you dynamically construct you SQL on the fly and only
> execute it once, they you can use the isc_dsql_execute_immediate(...)
> or its variant. You can still use this execute immediate with
> parameter marker, provided you construct your sqlda block.
> 5) Then you can commit the trans using isc_commit_transaction(...) call,
> followed by freeing the sqlda, if allocated, and the database handle
> resulted from the attach database. A word of caution if you use
> sqlda, you must make a copy of the allocated memory to be used to free
> them later on because after passing sqlda to any of the apis that use
> it, the address will be modified such that free the sqlda using the
> used pointer (in C/C++, I am not sure about in VB), will crash you
> program due to memory access exception.
> 6) Or else you can allocate a statment, using the
> isc_dsql_allocate_statement(...), then prepare it using the
> isc_dsql_prepare(...) api before you can use the isc_dsql_execute(...)
> api to execute.
> 7) You can use either input sqlda or output sqlda or both in these stmt.
> 8) You can use isc_dsql_sql_info(...) and walk the returned clustered
> info to determine affected row count.
> 9) There is no explicit result set, just like any non-object oriented
> API interface, but you can directly call the isc_dsql_fetch(...) to
> iterate thru the implicit result set. Here you will fine the use of
> output sqlda much more convenient to extract attribute for each
> fetched row. You also have to take care of date, time or timestamp
> datatype column using the isc_decode_timestamp(...) and its variant to
> map the FB date/time/timestamp encoding into you native programming
> language datatype.
> The overall API architecture is different from other database you may
> used to, but that is a fact of life that products evolve over time
> that the architecture and implementation that no two databases are
> alike unless the developers consciously make it so, which is a big
> effort by itself.
> So good luck and read up all the doc/books you can find, play with
> shipped examples, if in doubt, post a question to this forum.
> Everyone in this forum are very nice and do not laugh at "stupid
> questions".
> So take care!
> jml

The information transmitted herewith is sensitive information intended only for use to the individual or entity to which it is addressed. If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon, this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.