Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public DataTable GetTable2()
- {
- // Here we create a DataTable with four columns.
- DataTable table = new DataTable();
- table.Columns.Add("Dosage", typeof(int));
- table.Columns.Add("Drug", typeof(string));
- table.Columns.Add("Patient", typeof(string));
- table.Columns.Add("Date", typeof(DateTime));
- table.Columns.Add("testColumn", typeof(DateTime));
- SqlConnection connection = new SqlConnection();
- connection = Connection.getConnection();
- connection.Open();
- string tableName = "";
- tableName += "Subject";
- string Query = "select * from " + tableName + " where Status = 0;";
- SqlDataAdapter da = new SqlDataAdapter(Query, connection);
- DataSet ds = new DataSet();
- da.Fill(ds);
- DataRowCollection collection = ds.Tables[0].Rows;
- foreach (DataRow row in collection)
- {
- // Here we add five DataRows.
- table.Rows.Add(25, "Indocin", "David", DateTime.Now);
- table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now);
- table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now);
- table.Rows.Add(21, "Combivent", "Janet", DateTime.Now);
- table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now);
- }
- connection.Close();
- return table;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement