INF: Using dbdata() Versus dbbind()

Last reviewed: April 25, 1997
Article ID: Q39084

The information in this article applies to:
  • Microsoft SQL Server Programmer's Toolkit, version 4.2

SUMMARY

This article explains the relative tradeoffs between dbdata() and dbbind() when processing SQL Server data in an application program.

MORE INFORMATION

If you use dbdata() instead of dbbind(), you must handle data conversion yourself. All data will be in native SQL Server format. Variable-length character data will not have a trailing NULL. Money will be 8-byte scaled binary (1 = .01 cent). Datetime will be a pair of 4-byte binary integers, the first of which is the days since January 1, 1900 and the other of which is 1/300 of a second since midnight. If you use the provided data-conversion routines, you will be doing much the same thing that dbbind() does. For very large amounts of data, there will be an advantage to using dbdata() if the data is used in place. If it is copied somewhere else, that advantage is lost.

If the data will remain in native format while being processed in the program (that is, fixed-length character and binary data), there is a performance disadvantage with dbbind() because it will spend some time figuring out that it has nothing to do.

The biggest performance disadvantage with dbbind() is due to its biggest advantage: dynamic handling of data type and length at execution time. Note that you don't tell dbbind() the format or length of the data in the database. It gets that at execution time. What you do tell it is the format you want the data to be in for your program. If the actual data format differs from what you specified, dbbind() will convert it.

This provides insulation from changes in the definition of data in the database. If you use dbdata() and the format of the data in the database changes (such as ZIPCODE increasing from five to nine digits), your program will probably give incorrect results (if it runs at all); however, with dbbind(), the data will be converted and clipped automatically, and the program will run correctly without even being recompiled.

For highest performance, use dbdata(). For data independence and insulation from changes in database format, use dbbind().


Additional query words: DB-Library DB-Lib dblib Windows NT
Keywords : kbprg SSrvDB_Lib SSrvProg SSrvWinNT
Version : 4.2 | 4.2 | 4.2
Platform : MS-DOS OS/2 WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 25, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.