|
Question : Dataset - Column value - need correct syntax
|
|
C# (.Net - Web App) string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=C:\\temp\\MyAccessDB.mdb;" + "Persist Security Info=False;" + "Mode=Share Deny None;"; IDbConnection dbConnection = new System.Data.OleDb.OleDbConnection(connectionString); string queryString = "Select * FROM Employees"; IDbCommand dbCommand = new System.Data.OleDb.OleDbCommand(); dbCommand.CommandText = queryString; dbCommand.Connection = dbConnection; IDbDataAdapter dataAdapter = new System.Data.OleDb.OleDbDataAdapter(); dataAdapter.SelectCommand = dbCommand; DataSet dsOldDB = new DataSet(); dataAdapter.Fill(dsOldDB); dgEmployees.DataSource= dsOldDB.Tables[0]; // This works fine ... dgEmployees.DataBind();
... what I need to do is pull the individual column "values" out ... something like: sTemp = dsOldDB.Tables[0].Rows.Find("EmployeeName").ToString();
But this syntax doesn't work... what is the correct syntax??
|
|
Answer : Dataset - Column value - need correct syntax
|
|
i think its like this
string value = myDataSet.Tables[0].Rows[0]["keyword"].ToString();
or
string value = myDataSet.Tables[0].Rows[0].itemarray[0].tostring(); string value = myDataSet.Tables[0].Rows[0].itemarray[1].tostring(); string value = myDataSet.Tables[0].Rows[0].itemarray[2].tostring();
etc...
remember here you are going through rows and rows[0].itemarrays so not every row will have column property.
try that and let me know
|
|
|