VC++Á¬½ÓSQLServer
VC++Á¬½ÓSQLServer
/*
*Á¬½ÓSQL
*/
void CMFCSQLDlg::OnButton3()
{
// TODO: Add your control notification handler code here
_ConnectionPtr m_pConnection;
// ÔÚÓ¦ÓóÌÐòµÄInitInstanceº¯ÊýÀï¼ÓÈë
if(S_OK!=CoInitialize(NULL))
{
AfxMessageBox("³õʼ»¯COM¿â´íÎó!");
}else
{
AfxMessageBox("³õʼ»¯COM¿â³É¹¦!");
}
// Á¬½ÓÊý¾Ý¿â£º
HRESULT hr; //·µ»Ø½á¹û±äÁ¿
try
{
hr=m_pConnection.CreateInstance("ADODB.Connection"); //´´½¨Connection¶ÔÏó
if(SUCCEEDED(hr))
{
//hr=m_pConnection->Open("Provider=SQLOLEDB;Server=808644DA83B446C\SQLEXPRESS;Database=ChinabaseSQLServer;UserID=sa;pwd=123","","",adModeUnknown); //;Integrated Security=SSPI
m_pConnection->Open("Provider=SQLOLEDB.1;Server=808644DA83B446C\\SQLEXPRESS;DATABASE=ChinabaseSQLServer;UID=sa;PWD=123;","","",adModeUnknown);
MessageBox("Á¬½ÓSQLÔËÐгɹ¦!","³É¹¦",MB_OK);
_CommandPtr m_pCommand;
_RecordsetPtr m_pRecordset;
m_pCommand.CreateInstance("ADODB.Command");
_variant_t vNULL;
vNULL.vt = VT_ERROR;
Ïà¹ØÎĵµ£º
ÏÈǰÔÚ²âÊÔmysql connect c++½Ó¿ÚµÄʱºòÔËÐÐÆä¹Ù·½ÌṩµÄÀý×Ó
21.5.5.6. MySQL Connector/C++ Complete Example 2
The following code shows a complete example of how to use MySQL Connector/C++:
/* Copyright 2008 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify ......
ÔÚCÓëC++ÓïÑÔÖж¼´æÔڹؼü×Öconst,ºÜ¶àÈ˶¼¶Ô´Ë¹Ø¼ü×Ö´æÔÚÒ»¸ö´íÎóµÄÈÏʶ£¬ÈÏΪÔÚCÓïÑÔÖйؼü×ÖconstÊÇʹ±äÁ¿×÷Ϊһ¸ö³£Á¿£¬¼´½«±äÁ¿³£Á¿»¯£¬¾ÍÏñºê¶¨ÒåÒ»Ñù¡£¶øÔÚCÓïÑÔÖеĹؼü×ÖconstËùÆðµÄ×÷Óò¢²»ÊÇʹ±äÁ¿³£Á¿»°£¬¶øÊÇÏÞÖÆ±äÁ¿£¬Ê¹±äÁ¿³ýÁ˱»¸³³õÖµÍ⣬ÎÞ·¨±»ÖØÐ¸³Öµ¡£
¶øÔÚC++Öйؼü×Öconst²»½öʹ ......
µÚ4Õ ÔõÑù²ÅÄܱ£Ö¤²âÊÔЧ¹û£¿
4.1 ºâÁ¿²âÊÔЧ¹ûµÄ»ù±¾Ö¸±ê£º°×ºÐ¸²¸Ç
ºâÁ¿²âÊÔЧ¹ûµÄ»ù±¾Ö¸±êÊǰ׺и²¸ÇÂÊ£¬¼´Í³¼Æ²âÊÔ¶Ô´úÂëÂß¼µ¥Î»µÄ¸²¸Ç×´¿ö¡£´úÂëµÄÂß¼µ¥Î»Ö÷ÒªÓУºÓï¾ä(¿é)£¬Ìõ¼þ¡¢Åж¨¡¢·ÖÖ§¡¢Â·¾¶¡£³£Óõİ׺и²¸ÇÓÐÁùÖÖ£ºÓï¾ä¸²¸Ç¡¢Ìõ¼þ¸²¸Ç¡¢·ÖÖ§¸²¸Ç¡¢Åж¨Ìõ¼þ¸²¸Ç¡¢ÐÞÕýÅж¨Ìõ¼þ¸²¸Ç¡¢º ......
½ñÌìÓиö¸Õ¸Õ±ÏÒµµÄСÅóÓÑÎÊÎÒ¹ØÓÚvoid*µÄһЩÎÊÌ⣬¸ÕºÃÔÚÍøÉÏÕÒµ½ÁËһƪ±È½ÏÏêϸ˵Ã÷µÄÎÄÕ£¬×ªÔØÖ®......
1.¸ÅÊö
¡¡¡¡
¡¡¡¡Ðí¶à³õѧÕß¶ÔC/C++ÓïÑÔÖеÄvoid¼°voidÖ¸ÕëÀàÐͲ»ÉõÀí½â£¬Òò´ËÔÚʹÓÃÉϳöÏÖÁËһЩ´íÎó¡£±¾ÎĽ«¶Ôvoid¹Ø¼ü×ÖµÄÉî¿Ìº¬Òå½øÐнâ˵£¬²¢ÏêÊövoid¼°voidÖ¸ÕëÀàÐ͵ÄʹÓ÷½·¨Óë¼¼ÇÉ¡£
¡¡¡¡2.voidµÄº¬ ......
1. CµÄʵÏÖ
//stack.h
#ifndef STACK_H
#define STACK_H
#define STACK_CAPACITY 20//maximum size of stack
typedef int stackEle;
typedef struct
{
stackEle myArray[ STACK_CAPACITY ];
int myTop;
}stack;
//construct(initialize) an empty stack
stack *stack_init(void);
//return 1 if stack is em ......