WordTemplate oWW = new WordTemplate();
oWW.Open(@"c:\temp\template.doc");
string strSQL = "SELECT LastName, FirstName, " +
"TitleOfCourtesy, Address, City, Region, PostalCode " +
"FROM Employees WHERE EmployeeID=1";
//--- Create an OLEDB connection.
OleDbConnection oConn = new OleDbConnection(strConnString);
//--- Create an instance of the OleDbDataAdapter
//--- object.
OleDbDataAdapter oAdpt = new OleDbDataAdapter(strSQL, oConn);
//--- Create a DataSet and fill it with the data
//--- returned by the SQL database query.
DataSet oDS = new DataSet();
oAdpt.Fill(oDS);
//--- Pass the DataSet to SetDataSource. WordWriter
//--- will use the first DataTable in the DataSet as
//--- the data source.
oWW.SetDataSource(oDS, "Employee");
...
|