string ConnectionStr = "Data Source=(local);Initial Catalog=DataBaseName;Integrated Security=True";
SqlConnection Conn = new SqlConnection(ConnectionStr);
string CommandText = "select * from TableName where sh="+txtPerCode.Text;
SqlCommand sqlComm = new SqlCommand(CommandText, Conn);
SqlDataReader dr = sqlComm.ExecuteReader();
if (dr.HasRows)
{
DataTable dt = new DataTable();
dt.Load(dr);
dtgSavabeghList.DataSource = dt;
}