I have a table and I want to get specific column from my dataset my table only has one row.
Here is my code
private DataSet Ds = new DataSet();
public DataSet GetDataSet(string Query)
{
try
{
using (MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(connString))
{
MySqlDataAdapter Da = new MySqlDataAdapter(Query, conn);
Da.Fill(Ds);
conn.Close();
}
}
catch (Exception) { }
return Ds; //See image
}
public string getDataCellString(string headerName)
{
return "";//I want to get cell from heder name
}
Here is my question: How can I get a cell value from a header name?
If you only have one row you can:
public string getDataCellString(string headerName)
{
return Ds.Tables[0].Rows[0][headerName].ToString();
}