ODBC C±à³Ì·ÃÎÊÊý¾Ý¿â
н¨Ò»¸öWin32 Application£¬²¢ÔÚÏàÓ¦Îļþ¼ÐÏÂн¨Ò»¸öbook.mdb£¬ ÀïÃæÓÐÒ»¸ö±íBookInfo£¬±íÖÐÓÐÒÔϼ¸Àý£º
id:
BookName:
Author:
µÈ£»
//------------------------------------------------------------------------------
// Copyright (c) 2009 eryar All rights reserved.
//
// File : Main.cpp
// Author : eryar@163.com
// Date : 2009-11-8 16:09
// Version : 1.0v
//
// Description : ODBC±àд³ÌÐò·ÃÎÊÊý¾Ý¿âµÄ²Ù×÷ʾÀý¡£
//
//==============================================================================
#include <windows.h>
#include <sqlext.h>
#include <odbcinst.h>
#define IDM_FILE_OPEN 100001
#define IDM_FILE_EXIT 100002
#define IDM_HELP_CONTENT 200001
#define IDM_HELP_ABOUT 200002
#define IDM_DATA_CONNECT 300001
#define IDM_DATA_QUERY 300002
char* szAppName = "ODBC Demo";
HINSTANCE ghInst;
HMENU WinMainMenu(HWND);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd)
{
HWND hWnd;
MSG Msg;
WNDCLASS wndclass;
char* szClassName = "CODBC";
ghInst = hInstance;
wndclass.style = CS_HREDRAW|CS_VREDRAW;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.lpfnWndProc = WndProc;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szClassName;
if (!RegisterClass(&wndclass)) {
MessageBox(NULL, "This program requires Windows NT! ", szAppName, MB_OK|MB_ICONERROR);
return 0;
}
hWnd = CreateWindow(szClassName,
szAppName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hWnd, nShowCmd);
UpdateWindow(hWnd);
while (GetMessage(&Msg, NULL, 0, 0)) {
Tra
Ïà¹ØÎĵµ£º
ÊéÖÐÓм¸¸öÎÊÌâÓеãÄ£ºý¡£¼Ç¼һÏ¡£
Answer to Exercise 1-7
Write a program to print the value of EOF .
#include <stdio.h>
int main(void)
{
printf("The value of EOF is %d\n\n", EOF);
return 0 ......
ÒÔΪÒѾÕÆÎÕÌõ¼þ±àÒ룬Ԥ±àÒëµÄÒªÁìÁË£¬½á¹û»¹ÊÇ´æÔںܶàÒÅ©µÄµØ·½£¬ËùÒÔ¹æÕûһϣº
Ìõ¼þ±àÒ룺
1
#ifdef _XXXX
...³ÌÐò¶Î1...
#else
...³ÌÐò¶Î2...
#endif
Õâ±íÃ÷Èç¹û±êʶ·û_XXXXÒѱ»#defineÃüÁÒå¹ýÔò¶Ô³ÌÐò¶Î1½øÐбàÒ룻·ñÔò¶Ô³ÌÐò¶Î2½øÐбàÒë¡£
2
#ifndef _XXXX
...³ÌÐò¶Î1...
#else
...³ÌÐ ......
b/s ÊÇ brower/server ¾ÍÊÇÓÃä¯ÀÀÆ÷(Èçie)ΪӦÓóÌÐò¿Í»§¶Ë²Ù×÷·þÎñÆ÷¡£ÕâÑùÓÃä¯ÀÀÆ÷À´²Ù×÷¼òµ¥Ò×Ó㬵«ÊǶÔÊäÈëûÓкܺõÄÑéÖ¤¡£Â߼ʵÏÖ²»¶à¡£±¾µØÖ»ÊÇÓÃÓÚ»ñÈ¡Êý¾ÝÈ»ºó´ó²¿·ÖÑéÖ¤ÐèÒªÌá½»·þÎñÆ÷À´Íê³É¡£
c/s ÊÇclient/server ¿Í»§¶ËÈí¼þÔòÊÇÒ»¸öÓµÓкܶàÂß¼ÑéÖ¤µÄÈí¼þ£¬±¾µØÑéÖ¤³É¹¦ºó²ÅÌá½»·þÎñÆ÷¡£
ÎÒÕÒµ½µ ......
ÕâƪÎÄÕ½éÉÜÔÚLINUXϽøÐÐCÓïÑÔ±à³ÌËùÐèÒªµÄ»ù´¡ÖªÊ¶.ÔÚÕâƪÎÄÕµ±ÖÐ,ÎÒÃǽ«»áѧµ½ÒÔÏÂÄÚÈÝ:
Ô´³ÌÐò±àÒë
MakefileµÄ±àд
³ÌÐò¿âµÄÁ´½Ó
³ÌÐòµÄµ÷ÊÔ
Í·ÎļþºÍϵͳÇóÖú
--------------------------------------------------------------------------------
1.Ô´³ÌÐòµÄ±àÒë
ÔÚLinuxÏÂÃæ,Èç¹ûÒª±àÒëÒ»¸öC ......
ÕâÁ½Ìì¿´µ½ÓÐÈËÌÖÂ۵绰¼üÅÌÉϵÄ×Öĸ¡¢ºÅÂëºÍ×ÖĸµÄת»»£¬ÎÒÒ²Ëæ±ãдÁËÒ»¶Î
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define MAX_LEN 15
char *tbl_itoa[] =
{
"0", // 0
"1", // 1
"ABC", // 2
"DEF", // 3
"GHI", // 4
"JKL", // 5
"MNO", ......