📄 s21_08.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::Xml;
// 这是此应用程序的入口点
int _tmain(void)
{
// 创建一个Connection对象
SqlConnection* nwindConn =
new SqlConnection(S"Data Source=localhost;" \
S"Initial Catalog=northwind;" \
S"Integrated Security=SSPI;");
// 创建DataAdapter对象
SqlDataAdapter* catDA = new SqlDataAdapter();
// -- 设置SelectCommand属性 --
SqlCommand* selectCMD = new SqlCommand(
S"SELECT CategoryID, CategoryName FROM Categories",
nwindConn);
catDA->SelectCommand = selectCMD;
//' 打开连接对象,以建立到数据源的连接
nwindConn->Open();
// 创建DataSet对象,并使用DataAdapter填充
DataSet* catDS = new DataSet();
catDA->Fill(catDS, S"Categories");
// 写出到XML格式文件
Console::Write("Writting XML...");
catDS->WriteXml(S"Categories.xml", XmlWriteMode::WriteSchema);
Console::WriteLine("OK!");
nwindConn->Close();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -