无提示错误,不能显示数据
PrisidentMain prisidentMain=new PrisidentMain();try
{
//connect the database AssociationJSY
SqlConnection conn = new SqlConnection(prisidentMain.strconn);
prisidentMain.cmd.CommandType = CommandType.Text;
prisidentMain.cmd.Connection = conn;
prisidentMain.cmd.CommandText = "select * from "+tableName;
//open the database
conn.Open();
prisidentMain.dataset.Clear();
prisidentMain.sqlDataAdapter.SelectCommand = prisidentMain.cmd;
prisidentMain.sqlDataAdapter.Fill(prisidentMain.dataset,tableName);
prisidentMain.BindingSource0.DataSource=prisidentMain.dataset.Tables;
prisidentMain.dataGriShow.DataSource = prisidentMain.BindingSource0;
conn.Close();//close the database
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
这个运行正常,却不能显示,是不是因为new新窗体的原因呢》?该如何选择呢? C#通用DB类分享
http://www.ibcibc.com/forum.php?mod=viewthread&tid=69&fromuid=1
(出处: C#论坛-C#教程,ASP.NET教程)
这里有DB通用类, 不用那么麻烦
页:
[1]