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

📄 s21_06.cpp

📁 本书分为五个部分
💻 CPP
字号:
// 这是使用应用程序向导生成的 VC++ 
// 应用程序项目的主项目文件。

#include "stdafx.h"

#using <mscorlib.dll>
#include <tchar.h>

// 显示引用命名空间
#using <System.dll>
#using <System.Data.dll>
#using <System.Xml.dll>
using namespace System;
using namespace System::Data;
using namespace System::Data::SqlClient;
using namespace System::Data::OleDb;
using namespace System::Xml;

// 这是此应用程序的入口点
int _tmain(void)
{
    // 设置连接和查询字符串
    String* strConnection = 
        S"Provider=Microsoft.Jet.OLEDB.4.0;" \
        S"Data Source=D:\\visual studio projects\\database\\ENorthwind.mdb;";
    String* strSQL = S"SELECT * FROM Categories";

    // 创建Connection和DataAdapter对象
    OleDbConnection* nwindConn = 
        new OleDbConnection(strConnection);
    OleDbDataAdapter* custAD = 
        new OleDbDataAdapter(strSQL, nwindConn);

    // 自动生成命令
    OleDbCommandBuilder* custCD = 
        new OleDbCommandBuilder(custAD);
    custAD->UpdateCommand = custCD->GetUpdateCommand();
    custAD->InsertCommand = custCD->GetInsertCommand();
    custAD->DeleteCommand = custCD->GetDeleteCommand();

    // 显示自动生成命令的命令字符串
    Console::WriteLine(S"SelectCommand = \n{0}", 
        custAD->SelectCommand->CommandText);
    Console::WriteLine(S"UpdateCommand = \n{0}", 
        custAD->UpdateCommand->CommandText);
    Console::WriteLine(S"InsertCommand = \n{0}", 
        custAD->InsertCommand->CommandText);
    Console::WriteLine(S"DeleteCommand = \n{0}", 
        custAD->DeleteCommand->CommandText);

    nwindConn->Close();

    return 0;
}

⌨️ 快捷键说明

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