无法将数据集值绑定到标签

unable to bind dataset value to label

在将 DataSet 值分配给 Label 时得到 System.Data.DataRow 数据不准确。

DataSet ds = new DataSet();
SqlCommand cmd = new SqlCommand("select top 1 text from tbl_HomepageContent where company = 'jagsar'", con);
//cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
lblHomepageContent.Text = ds.Tables[0].Rows[0].ToString();

我不会使用 DataSet 来确定一个值。 ExecuteScalar 产生更少的开销

string Command = "select top 1 text from tbl_HomepageContent where company = @company";
using (SqlConnection myConnection = new SqlConnection(con))
{
    myConnection.Open();
    using (SqlCommand myCommand = new SqlCommand(Command, myConnection))
    {
        myCommand.Parameters.Add(new SqlParameter("@company", "jagsar"));
        lblHomepageContent.Text = (string)myCommand.ExecuteScalar();
    }
}