为什么DataGridView控件中没有显示记录?
public partial class frmBook : Form{
public frmBook()
{
InitializeComponent();
}
public static string str = "";
public static string strConn = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=db_LibraryMIS;Data Source=2011-20120218ZM";
//在dvgBook空间上显示图书表的数据
public void showinf()
{
using (SqlConnection con = new SqlConnection(strConn))
{
DataTable dt = new DataTable(); //内存中开辟一个内存数据表
SqlDataAdapter da = new SqlDataAdapter("select BID as 图书编号,BName as 图书名称,BWrite as 作者,BPublish as 出版社,BDtate as 出版日期,BPrice as 价格,BNum as 数量,BType as 类型,BRemark as 备注 from tb_Book order by BID", con);
da.Fill(dt);
this.dvgBook.DataSource = dt.DefaultView;
}
}
private void frmBook_Load(object sender, EventArgs e)
{
showinf();
}
DataGridView控件如下图显示空空的: