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 OleDbCommand
OleDbCommand oCmd = new OleDbCommand(strSQL, oConn);
//--- Get an OleDbDataReader
oConn.Open();
OleDbDataReader oReader =
oCmd.ExecuteReader(CommandBehavior.CloseConnection);
//--- Pass the DataReader to SetDataSource.
oWW.SetDataSource(oReader, "Employee");
//--- Close the reader (should do this in a finally block)
oReader.Close();
...
|