How do I read data from a DataSet in WPF? I have a train schedule table with just 2 columns and I want to be able to read the departure times and calculate when the next train is leaving. For example, the time now is 12:29 and my application should tell me that next train will depart at 12:33.
I already googled left and right. I'm on .NET 3.5.
To read or write a data in Kaggle Kernel is the same as how you did in R or Python, the only thing to take note is the relative path to access the data. After data is added into notebook, click the dataset. Click on the "copy icon" to copy the path. Now you can paste it.
DataSet resembles database. DataTable resembles database table, and DataRow resembles a record in a table. If you want to add filtering or sorting options, you then do so with a DataView object, and convert it back to a separate DataTable object.
If you're using database to store your data, then you first load a database table to a DataSet object in memory. You can load multiple database tables to one DataSet, and select specific table to read from the DataSet through DataTable object. Subsequently, you read a specific row of data from your DataTable through DataRow. Following codes demonstrate the steps:
SqlCeDataAdapter da = new SqlCeDataAdapter(); DataSet ds = new DataSet(); DataTable dt = new DataTable(); da.SelectCommand = new SqlCommand(@"SELECT * FROM FooTable", connString); da.Fill(ds, "FooTable"); dt = ds.Tables["FooTable"]; foreach (DataRow dr in dt.Rows) { MessageBox.Show(dr["Column1"].ToString()); }
To read a specific cell in a row:
int rowNum // row number string columnName = "DepartureTime"; // database table column name dt.Rows[rowNum][columnName].ToString();
If ds is the DataSet, you can access the CustomerID column of the first row in the first table with something like:
DataRow dr = ds.Tables[0].Rows[0]; Console.WriteLine(dr["CustomerID"]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With