⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vcg07.htm

📁 Visual C++与数据库的连接经典实例
💻 HTM
📖 第 1 页 / 共 5 页
字号:

</TABLE></CENTER><BR>

<A NAME="E70E47"></A>

<H5 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Date, Time, and Timestamp Functions</B></FONT></CENTER></H5>

<BR>

<P>Table 7.4 lists the ODBC date, time, and timestamp functions and their equivalent functions, where available, in Visual C++.

<BR>

<BR>

<P ALIGN=CENTER>

<CENTER>

<FONT COLOR="#000080"><B>Table 7.4. The date/time scalar functions of ODBC version 1.0.</B></FONT></CENTER>

<BR>



<CENTER><TABLE  BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 CELLPADDING=3 >

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<I>ODBC Date/Time Function</I>

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

<I>Purpose</I>

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

NOW()

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Returns the date and time in TIMESTAMP format.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

CURDATE()

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Returns the current date.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

CURTIME()

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Returns the current time.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

DAYOFMONTH(<I>date_exp</I>)

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Returns the day of the month.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

DAYOFWEEK(<I>date_exp</I>)

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Returns the day of the week (Sunday = 1).

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

DAYOFYEAR(<I>date_exp</I>)

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Returns the Julian date.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

HOUR(<I>time_exp</I>)

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Returns the hour (0 to 23).

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

MINUTE(<I>time_exp</I>)

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Returns the minute (0 to 59).

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

MONTH(<I>date_exp</I>)

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Returns the number of the month.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

QUARTER(<I>date_exp</I>)

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Returns the number of the calendar quarter.

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

SECOND(<I>time_exp</I>)

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Returns the second (0 to 60).

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

WEEK(<I>date_exp</I>)

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Returns the week number (1 to 52).

</FONT>

<TR>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

YEAR(<I>date_exp</I>)

</FONT>

<TD VALIGN=top  BGCOLOR=#80FFFF ><FONT COLOR=#000080>

Returns the four-digit year.</FONT>

</TABLE></CENTER><BR>

<A NAME="E69E148"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>ODBC Initialization Files</B></FONT></CENTER></H4>

<BR>

<P>The ODBC administrator applications, ODBCCP32.DLL and ODBCAD32.EXE, create or delete entries in the two ODBC initialization files in your \WINDOWS directory. The purpose of these two files and the relevance of the entries they contain are explained in the following sections.

<BR>

<BR>

<A NAME="E70E48"></A>

<H5 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>ODBCINST.INI</B></FONT></CENTER></H5>

<BR>

<P>After installing the ODBC driver manager and administrator files, the first step in providing SQL connectivity is to add ODBC drivers for the types of databases to which your applications connect. When you install an ODBC driver, the driver setup application adds an entry to the [ODBC Drivers] section of the installed drivers initialization file, ODBCINST.INI, and marks the driver as available with an Installed value. For the 32-bit drivers, the same technique is used, with the section named as [ODBC 32 bit Drivers]. It appears that 32-bit drivers use the ODBCINST.INI file for backwards compatibility.

<BR>

<P>The contents of the ODBCINST.INI file of the workstation computer used to write this book are as follows:

<BR>

<PRE>

<FONT COLOR="#000080">[ODBC Drivers]

Microsoft Excel Driver (*.xls)=Installed

Microsoft Text Driver (*.txt; *.csv)=Installed

SQL Server=Installed

Microsoft Access Driver (*.mdb)=Installed

Microsoft Dbase Driver (*.dbf)=Installed

Microsoft FoxPro Driver (*.dbf)=Installed

Access Data (*.mdb)=Installed

[ODBC Translators]

MS Code Page Translator=Installed

[Microsoft Access Driver (*.mdb) (32 bit)]

Driver=C:\WINDOWS\SYSTEM\odbcjt32.dll

Setup=C:\WINDOWS\SYSTEM\odbcjt32.dll

32Bit=1

[ODBC 32 bit Drivers]

Microsoft Access Driver (*.mdb) (32 bit)=Installed

Microsoft Dbase Driver (*.dbf) (32 bit)=Installed

Microsoft Excel Driver (*.xls) (32 bit)=Installed

Microsoft FoxPro Driver (*.dbf) (32 bit)=Installed

Microsoft Paradox Driver (*.db ) (32 bit)=Installed

Microsoft Text Driver (*.txt; *.csv) (32 bit)=Installed

SQL Server (32 bit)=Installed

Oracle (32 bit)=Installed

CR SQLBase (32 bit)=Installed

CR Oracle7 (32 bit)=Installed

CR Sybase System 10 (32 bit)=Installed

[Microsoft Dbase Driver (*.dbf) (32 bit)]

Driver=C:\WINDOWS\SYSTEM\odbcjt32.dll

Setup=C:\WINDOWS\SYSTEM\oddbse32.dll

32Bit=1

[Microsoft Excel Driver (*.xls) (32 bit)]

Driver=C:\WINDOWS\SYSTEM\odbcjt32.dll

Setup=C:\WINDOWS\SYSTEM\odexl32.dll

32Bit=1

[Microsoft FoxPro Driver (*.dbf) (32 bit)]

Driver=C:\WINDOWS\SYSTEM\odbcjt32.dll

Setup=C:\WINDOWS\SYSTEM\odfox32.dll

32Bit=1

[Microsoft Paradox Driver (*.db ) (32 bit)]

Driver=C:\WINDOWS\SYSTEM\odbcjt32.dll

Setup=C:\WINDOWS\SYSTEM\odpdx32.dll

32Bit=1

[Microsoft Text Driver (*.txt; *.csv) (32 bit)]

Driver=C:\WINDOWS\SYSTEM\odbcjt32.dll

Setup=C:\WINDOWS\SYSTEM\odtext32.dll

32Bit=1

[Microsoft Excel Driver (*.xls)]

Driver=C:\WINDOWS\SYSTEM\odbcjt16.dll

Setup=C:\WINDOWS\SYSTEM\odexl16.dll

SQLLevel=0

FileExtns=*.xls

FileUsage=1

DriverODBCVer=02.01

ConnectFunctions=YYN

APILevel=1

[Microsoft Text Driver (*.txt; *.csv)]

Driver=C:\WINDOWS\SYSTEM\odbcjt16.dll

Setup=C:\WINDOWS\SYSTEM\odtext16.dll

SQLLevel=0

FileExtns=*.,*.asc,*.csv,*.tab,*.txt

FileUsage=1

DriverODBCVer=02.01

ConnectFunctions=YYN

APILevel=1

[SQL Server]

Driver=C:\WINDOWS\SYSTEM\sqlsrvr.dll

Setup=C:\WINDOWS\SYSTEM\sqlsrvr.dll

APILevel=1

ConnectFunctions=YYY

DriverODBCVer=02.01

FileUsage=0

SQLLevel=1

[SQL Server (32 bit)]

Driver=C:\WINDOWS\SYSTEM\sqlsrv32.dll

Setup=C:\WINDOWS\SYSTEM\sqlsrv32.dll

32Bit=1

[Microsoft Access Driver (*.mdb)]

Driver=C:\WINDOWS\SYSTEM\odbcjt16.dll

Setup=C:\WINDOWS\SYSTEM\odbcjt16.dll

SQLLevel=0

FileExtns=*.mdb

FileUsage=2

DriverODBCVer=02.01

ConnectFunctions=YYN

APILevel=1

[Microsoft Dbase Driver (*.dbf)]

Driver=C:\WINDOWS\SYSTEM\odbcjt16.dll

Setup=C:\WINDOWS\SYSTEM\oddbse16.dll

SQLLevel=0

FileExtns=*.dbf,*.ndx,*.mdx

FileUsage=1

DriverODBCVer=02.01

ConnectFunctions=YYN

APILevel=1

[Microsoft FoxPro Driver (*.dbf)]

Driver=C:\WINDOWS\SYSTEM\odbcjt16.dll

Setup=C:\WINDOWS\SYSTEM\odfox16.dll

SQLLevel=0

FileExtns=*.dbf,*.cdx,*.idx,*.ftp

FileUsage=1

DriverODBCVer=02.01

ConnectFunctions=YYN

APILevel=1

[MS Code Page Translator]

Translator=C:\WINDOWS\SYSTEM\mscpxlt.dll

Setup=C:\WINDOWS\SYSTEM\mscpxlt.dll

[Access Data (*.mdb)]

Driver=C:\WINDOWS\SYSTEM\simba.dll

Setup=C:\WINDOWS\SYSTEM\simadmin.dll

&quot;FileUsage&quot;=2

&quot;FileExtns&quot;=*.mdb

&quot;DirectConnect&quot;=0

[Oracle (32 bit)]

Driver=C:\WINDOWS\SYSTEM\vsorac32.dll

Setup=C:\WINDOWS\SYSTEM\orstub32.dll

32Bit=1

[CR SQLBase (32 bit)]

Driver=C:\WINDOWS\SYSTEM\crgup07.dll

Setup=C:\WINDOWS\SYSTEM\crgup07.dll

32Bit=1

[CR Oracle7 (32 bit)]

Driver=C:\WINDOWS\SYSTEM\cror707.dll

Setup=C:\WINDOWS\SYSTEM\cror707.dll

32Bit=1

[CR Sybase System 10 (32 bit)]

Driver=C:\WINDOWS\SYSTEM\crsyb07.dll

Setup=C:\WINDOWS\SYSTEM\crsyb07.dll

32Bit=1</FONT></PRE>

<P>The preceding ODBCINST.INI file includes entries for the following 16-bit datasources, which can be used with legacy 16-bit applications:

<BR>

<UL>

<LI>Six ODBC datasource types are provided by the Microsoft ODBC Desktop Database Drivers kit. They're included with 16-bit applications that come supplied with Microsoft ODBC:

<BR>

<BR>Microsoft Excel Driver (*.XLS)

<BR>Microsoft Text Driver (*.TXT, *.CSV)

<BR>SQL Server

<BR>Microsoft Dbase Driver (*.DBF)

<BR>Microsoft FoxPro Driver (*.DBF)

<BR>Access Data (Simba version comes with ODBC driver pack)

<BR>

<BR>

<LI>The Access 2.0 driver that is supplied with the Microsoft Office product.

<BR>

<BR>Microsoft Access Driver. (The Jet driver, which comes with Microsoft Office 2, can't be used with MFC applications.)

<BR>

<BR>

</UL>

<P>The preceding ODBCINST.INI file includes entries for the following 32-bit datasources, which can be used with newer 32-bit applications:

<BR>

<UL>

<LI>Six ODBC datasource types are provided by the Microsoft ODBC Desktop Database Drivers kit. They're included with 32-bit applications that come supplied with Microsoft ODBC:

<BR>

<BR>Microsoft Access Driver (*.MDB) (32-bit)

<BR>Microsoft Dbase Driver (*.DBF) (32-bit)

<BR>Microsoft Excel Driver (*.XLS) (32-bit)

<BR>Microsoft FoxPro Driver (*.DBF) (32-bit)

<BR>Microsoft Paradox Driver (*.DB) (32-bit)

<BR>Microsoft Text Driver (*.TXT, *.CSV) (32-bit)

<BR>

<BR>

<LI>The ODBC SQL server provided by the Microsoft ODBC Desktop Database Drivers kit and included with 32-bit applications that come supplied with Microsoft ODBC:

<BR>

<BR>SQL Server (32-bit)

<BR>

<BR>

<LI>The ODBC Oracle driver provided by the Microsoft ODBC Desktop Database Drivers kit and included with 32-bit applications that come supplied with Microsoft ODBC:

<BR>

<BR>Oracle (32-bit) installed

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -