[C#] 纯文本查看 复制代码 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[tableName];
prisidentMain.dataGriShow.DataSource = prisidentMain.BindingSource0;
conn.Close();//close the database
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
|