以下C#代码如何写成方法,然后去调用
DataTable dt = new DataTable();string sql = "select * from yh where 用户名='" + yhm.Text.Trim() + "'and 密码='" + mm.Text.Trim() + "'";
SqlDataAdapter adp = new SqlDataAdapter(sql, myclass.opendata());
adp. = sql;
adp.Fill(dt);
//以上代码如何写成方法后,像下面一样做判断
if (dt != null)
{
if (dt.Rows.Count > 0)
{
main zt = new main();
zt.Show();
this.Hide();
}