Use ODBC to access the database (2)

Source: Internet
Author: User

If you use C/C ++ for development, there will be a data conversion problem between ODBC and ODBC, because some ODBC data types do not exist in C. Therefore, do not use int, float or other types of C language to define variables during ODBC development. Instead, use the data types defined by ODBC to define variables, such as sqlinteger and sqlfloat. ODBC defines the data types used in the C language and ODBC in macro-defined mode:

C type identifier

Odbc c typedef

C type

SQL _c_char

Sqlchar *

Unsigned char *

SQL _c_sshort

Sqlsmallint

Short int

SQL _c_ushort

Sqlusmallint

Unsigned short int

SQL _c_slong

Sqlinteger Long int

SQL _c_ulong

Sqluinteger

Unsigned long int
SQL _c_float

Sqlreal

Float

SQL _c_double

Sqldouble, sqlfloat

Double

SQL _c_bit

Sqlchar

Unsigned char
SQL _c_stinyint

Sqlschar

Signed Char

SQL _c_utinyint

Sqlchar

Unsigned char

SQL _c_sbigint

Sqlbigint

_ Int64

SQL _c_ubigint

Sqlubigint

Unsigned _ int64

SQL _c_binary

Sqlchar *

Unsigned char *

SQL _c_xml

Sqlchar *

Unsigned char *
SQL _c_bookmark Bookmark

Unsigned long int

SQL _c_varbookmark

Sqlchar *

Unsigned char *

SQL _c_type_date

SQL _date_struct

Struct tagdate_struct
{
Sqlsmallint year;
Sqlusmallint month;
Sqlusmallint Day;
} Date_struct;

SQL _c_type_time

SQL _time_struct

Struct tagtime_struct
{
Sqlusmallint hour;
Sqlusmallint minute;
Sqlusmallint second;
} Time_struct;

SQL _c_type_timestamp

SQL _timestamp_struct

Struct tagtimestamp_struct
{
Sqlsmallint year;
Sqlusmallint month;
Sqlusmallint Day;
Sqlusmallint hour;
Sqlusmallint minute;
Sqlusmallint second;
Sqluinteger fraction;
} Timestamp_struct

SQL _c_numeric

SQL _numeric_struct

Struct tagsql_numeric_struct
{
Sqlchar precision;
Sqlschar scale;
Sqlchar sign;
Sqlchar Val [SQL _max_numeric_len];
} SQL _numeric_struct;

SQL _c_guid

Sqlguid

Struct tagsqlguid {
DWORD data1;
Word data2;
Word data3;
Byte data4 [8];
} Sqlguid;

All C interval Data Types

SQL _interval_struct

See the "C interval structure" section, later in this appendix.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.