在以下代码中,我可以看到我的DataSet
已经填充了数据,但我的DataGridView
没有显示任何内容:
string sql = "SELECT * FROM MyTable";
try
{
ds = new DataSet("Downloads");
using (IDbConnection conn = dataFactory.GetDbConnection())
{
conn.ConnectionString = Common.Conf.ConnectionString;
da = dataFactory.GetDbDataAdapter();
IDbCommand cmd = dataFactory.GetDbCommand();
cmd.CommandText = sql;
cmd.Connection = conn;
da.SelectCommand = cmd;
conn.Open();
da.Fill(ds);
conn.Close();
}
dgv.DataSource = ds;
dgv.DataMember = "Downloads";
if (dgv.Rows == null || dgv.Rows.Count == 0)
lblDownloads.Text = "No download history found";
}
catch (Exception ex)
{
return false;
}