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 DataTable and fill it with the data
//--- returned by the SQL database query.
DataTable oDT = new DataTable();
oAdpt.Fill(oDT);
//--- Pass the DataTable to SetDataSource.
oWW.SetDataSource(oDT, "Employee");
|