ch10_13.cs
来自「《c#技术内幕代码》」· CS 代码 · 共 42 行
CS
42 行
using System;
using System.Data;
using System.Data.ADO;
using System.Xml;
public class CH10_2
{
public static void Main ()
{
// Define the connection string
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=NWIND.MDB";
// Define our selection criteria
string strRec = "SELECT EmployeeID, FirstName, LastName, Title FROM Employees ORDER by LastName";
// Create the connection object, using our connection string
ADOConnection myConn = new ADOConnection(strConn);
// Create the command object from our selection criteria string
ADODataSetCommand myCmd = new ADODataSetCommand( strRec, myConn );
try
{
// This will do the connection to the database
myConn.Open();
DataSet myDataSet = new DataSet();
myDataSet.Tables.Add("Employees");
myCmd.FillDataSet(myDataSet,"Employees");
myDataSet.WriteXmlSchema("ch10_13.xml");
myDataSet.WriteXml("ch10_13.xml");
}
catch ( Exception e )
{
Console.WriteLine("Exception {0}", e );
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?